问题
http://i.imgur.com/j7hStIG.png
Hi I need help repairing this image using for loops. I know I have to identify the bad pixels first and fill them in. thanks. PS I am very new to matlab
clear
clc
format compact
filenameIN = uigetfile('.bmp','Picture');
noisyRGBarray = imread(filenameIN);
figure(1)
imshow(noisyRGBarray)
y = noisyRGBarray;
[m,n]=size(y)
clean=[];
for i=2:m-1
for j=2:n-1
if y(i,j)% clean add new
clean = [ clean, y(i,j) ]
end
end
end
Im pretty sure the for statemetn is wrong and I do not know wat to do from here. I need help writing the for loop to go through the image matrix to identify the black and white pixels.
回答1:
Try running a median filter on your image. See here for an example.
If you must use a for
loop for learning reasons, please explain what you consider to be a "bad pixel" (black? different from neighbors in some way?), attempt to identify such a pixel based on the criteria you settle on, and adjust the value of that pixel.
In general, you should not adopt the approach of starting with an empty array and growing it one pixel at a time. Rather, create the output image as a copy of the input (clean=noisyRGBarray;
) or initialize with zeros (clean=zeros(size(noisyRGBarray))
), and modify the bad pixels (clean(i,j,:)=...
);
来源:https://stackoverflow.com/questions/19260083/repairing-pixelated-image-using-matlab-help-needed