Tasvir yorug`ligini o`zgartirish
a = 20;
b = 70;
randnumber = randsrc(1,1,[a:b]);
O = imread('wolf.jpg');
[x,y] = size(O);
for i = 1:1:x
for j = 1:1:y
H(i,j) = O(i,j) + randnumber;
L(i,j) = O(i,j) - randnumber;
end
end
subplot(1,2,1),subimage(H),title('High brightness image');
subplot(1,2,2),subimage(L),title('Low brightness image');
6-rasm. Tasvirni o’zgartirish kodi.
7-rasm. Tasvirni yorug’ligini o’zgartirilgan xolati.
Tasvir kontrastini o`zgartirish
a = randsrc(1,1,[1:3]);
a1 = rand(1,1);
b = randsrc(1,1,[0:30]);
O = imread('wolf.jpg');
[x,y] = size(O);
H = O*a;
L = O*a1;
for i = 1:1:x
for j = 1:1:y
H(i,j) = H(i,j) + b;
L(i,j) = L(i,j) + b;
end
end
subplot(1,2,1),imshow(H),title('Yuquri kontrastli tasvir’);
subplot(1,2,2),imshow(L),title('Quyi kontrastli tasvir’);
8-rasm. Tasvirni kontrakstini o’zgartirish.
Tasvir gistogramma qiymatlarini tenglashtirish
Code:
I1 = imread('jiraf.png ');
I2 = histeq(I1);
subplot(1,2,1),imhist(I1),title('Avvalgi holat');
subplot(1,2,2),imhist(I2),title('Keyingi holat');
9-Rasm. Tasvirni gistogrammasini o’zgartirish.
3-vazifa. Tasvirda morfologik amallar bajarish
Ushbu amaliy ishda binar (binary) va kulrang (grayscale) tasvirlarda morfologik amallarni bajarish ko'zda tutilgan. Bunda tasvirlar ustida quyidagi morfologik amallarni bajarish lozim:
morfologik erosion
morfologik dilation
morfologik opening
morfologik closing
Binar tasvir
Erosion
A=imread('helic.jpg');
se = strel('cube',15);
%% Erosion
aa = imopen(A,se);
%% Dilation
bb = imclose(A,se);
%% Opening
dd = imclose(aa,se);
%% Closing
cc = imopen(A,se);
%% Plotting
subplot(121)
imshow(A)
subplot(122)
imshow(aa,[])
10-rasm. Tasvirni erosion funktsiyasidan keying xolati.
Dilation
A=imread('helic.jpg ');
se = strel('cube',15);
%% Erosion
aa = imopen(A,se);
%% Dilation
bb = imclose(A,se);
%% Opening
dd = imclose(aa,se);
%% Closing
cc = imopen(A,se);
%% Plotting
subplot(121)
imshow(A)
subplot(122)
imshow(bb,[])
11-rasm. Tasvirni dilation funktsiyasidan keying xolati.
Opening
A=imread('helic.jpg');
se = strel('cube',15);
%% Erosion
aa = imopen(A,se);
%% Dilation
bb = imclose(A,se);
%% Opening
dd = imclose(aa,se);
%% Closing
cc = imopen(A,se);
%% Plotting
subplot(121)
imshow(A)
subplot(122)
imshow(dd,[])
12-rasm. Tasvirni opening funktsiyasidan keying xolati.
Closing
A=imread('helic.jpg');
se = strel('cube',7);
%% Erosion
aa = imopen(A,se);
%% Dilation
bb = imclose(A,se);
%% Opening
dd = imclose(aa,se);
%% Closing
cc = imopen(A,se);
%% Plotting
subplot(121)
imshow(A)
subplot(122)
imshow(cc,[])
13-rasm. Tasvirni closing funktsiyasidan keying xolati.
|