5. Section
(1) The total number of pixels representing the tumor for the first patient was
January:S1=100+200+300+200+100=900 pixels
August: S8=100+200+300+200+100=900 pixels
This shows that the size of the tumor does not change. The mean gray level of the
tumor region is:
Jan: f1=(100*5+200*6+300*7+200*8+100*9)/900=7
Aug: f8=(100*7+200*8+300*9+200*10+100*11)/900=9
Thus, the tumor density increased
(2) to the second patient indicating that the total number of pixels in the tumor was
April: S4=100+200+300+200+100=900
Dec: S12=100+150+200+150+50=650
The mean value of gray scale in the area where the tumor was supposed to be small
was
April: f4=(100*8+200*9+300*10+200*11+100*12)/900=10
Dec: f12=(100*8+150*9+200*10+150*11+50*12)/900=9.85
The tumor density is low
6. Section
Since the neighborhood of (x, y) is Sxy, g (s t)^Q (s,t) Sxy
is constant. Therefore, the weight value of pixel (s, t) depends on g (s, t) Q:
• When Q>0, the larger the gray value g (s, t) , the larger the weight value g (s, t) Q,
and the greater the contribution to the filtering result; In contrast, the smaller the gray
value g (s, t) , the smaller the weight value g (s, t) Q, and the smaller the contribution to
the filtering result. So when Q > 0, it is effective for pepper noise.
• When Q< 0, the bigger the gray value g (s, t) of each pixel under the filter mask is, the
smaller the weight value g (s, t) Q is, and the smaller the contribution to the filter result is; In contrast, the smaller the gray value g(s,t) is, the bigger the weight value g (s, t) Q is, and the greater the contribution to the filtering result. So when Q< 0, it is effective to remove salt noise.
from (1) and (2) , if the wrong Q symbol is chosen, for example, if the noise in the image is salt noise and Q>0 is selected, then the weight of the filter will increase with the increase of the gray level under the mask, and the salt noise is white gray level, so in this case, the salt noise makes a great contribution to the filter result, so it doesn’t get rid of the noise, but brings the salt noise to the adjacent pixels, which makes the result worse. On the other hand, if the noise in the image is pepper noise, and choose Q<0, the gray level of pepper noise is 0 or close to 0, its weight value will be very big, to the filter result contribution is very big, therefore cannot remove the noise.
7.Section
Clear all;
Rgb_image=imread(‘flower.jpg’); % read hand image
[mmax,nmax,kmax]=size(rgb_image) % size of 3D image, kmax=1,2,3
For m=1:mmax
For n=1:nmax
fR(m,n)=rgb_image(m,n,1); %red components M*N
fG(m,n)=rgb_image(m,n,2); %green components M*N
fB(m,n)=rgb_image(m,n,3); %blue components M*N
end
ekma
Low_HighfR=stretchlim(fR)
% low and high values of red component
[hr,x1]=imhist(fR,256); % distribution of red component
[hg,x2]=imhist(fG,256); % distribution of green component
[hb,x3]=imhist(fB,256); % distribution of blue component
Rgb=cat(3,fR,fG,fB); % image before histeq
fR1=histeq(fR,256); % histeq
fG1=histeq(fG,256); % histeq
fB1=histeq(fB,256); % histeq
rgb1=cat(3,fR1,fG1,fB1); % image after histeq
figure(1)
semilogy(x1,hr,’r-‘,x2,hg,’b-‘,x3,hb,’k-‘);
xlabel(‘gray level’)
ylabel(‘counts’)
title(‘RGB level distribution of original image’)
grid on;
pause;
figure(2)
subplot(221),imshow(rgb),title(‘image before histeq’); %image before
subplot(222),imshow(fR),title(‘red comp of original image’); %
subplot(223),imshow(fG),title(‘green comp of original image’); %
subplot(224),imshow(fB),title(‘blue comp of original image’); %
pause;
figure(3)
subplot(121),imshow(rgb),title(‘image before histeq’);
subplot(122),imshow(rgb1),title(‘image after histeq’);
B)
Clear all;
Rgbimage=imread(‘flower.jpg’); % read image
[mmax,nmax,kmax]=size(rgbimage) % size of 3D image, kmax=1,2,3
For m=1:mmax
For n=1:nmax
fR(m,n)=rgbimage(m,n,1); %red components M*N
fG(m,n)=rgbimage(m,n,2); %green components M*N
fB(m,n)=rgbimage(m,n,3); %blue components M*N
end
end
HSVimage=rgb2hsv(rgbimage);
H=HSVimage(:,:,1);
S=HSVimage(:,:,2);
V=HSVimage(:,:,3);
V1=histeq(V,256); % histeq
HSV=cat(3,H,S,V);
HSV1=cat(3,H,S,V1);
Rgb=hsv2rgb(HSV);
Rgb1=hsv2rgb(HSV1);
Figure(1)
Imshow(rgbimage),title(‘original image’); %
Figure(2)
Imshow(rgb),title(‘recreated image without equ’); %
Figure(3)
Imshow(rgb1),title(‘recreated image with equ’); %
Figure(4)
Subplot(121),imhist(V),title(‘without equ’);
Subplot(122),imhist(V1),title(‘with equ’);
c)
clear all;
rgbimage=imread(‘flower.jpg’); % read image
[mmax,nmax,kmax]=size(rgbimage)
HSVimage=rgb2hsv(rgbimage);
H=HSVimage(:,:,1);
S=HSVimage(:,:,2);
V=HSVimage(:,:,3);
V1=histeq(V,256); % histeq
HSV=cat(3,H,S,V);
HSV1=cat(3,H,S,V1);
Rgb=hsv2rgb(HSV);
Rgb1=hsv2rgb(HSV1);
Figure(1)
Subplot(121),imhist(V),title(‘without equ’);
Subplot(122),imhist(V1),title(‘with equ’);
D)
Clear all;
Rgbimage=imread(‘flower.jpg’); % read image
[mmax,nmax,kmax]=size(rgbimage) % size of 3D image, kmax=1,2,3
For m=1:mmax
For n=1:nmax
fR(m,n)=rgbimage(m,n,1); %red components M*N
fG(m,n)=rgbimage(m,n,2); %green components M*N
fB(m,n)=rgbimage(m,n,3); %blue components M*N
end
end
HSVimage=rgb2hsv(rgbimage);
H=HSVimage(:,:,1);
S=HSVimage(:,:,2);
V=HSVimage(:,:,3);
V1=histeq(V,256); % histeq
HSV=cat(3,H,S,V);
HSV1=cat(3,H,S,V1);
Rgb=hsv2rgb(HSV);
Rgb1=hsv2rgb(HSV1);
Figure(1)
Imshow(rgbimage),title(‘original image’); %
Figure(2)
Imshow(rgb1),title(‘recreated image with equ’); %
Do'stlaringiz bilan baham: |