使用matlab修复像素化图像需要帮助 [英] Repairing pixelated image using matlab Help needed

查看:177
本文介绍了使用matlab修复像素化图像需要帮助的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

http://i.imgur.com/j7hStIG.png



您好,我需要帮助修复使用for循环这个图像。我知道我必须首先确定坏像素并填充它们。谢谢。 PS我是非常新的matlab

$ $ p $ code $清除
clc
格式压缩

文件名IN = uigetfile('。bmp','图片');
noisyRGBarray = imread(文件名IN);
figure(1)
imshow(noisyRGBarray)
y = noisyRGBarray;
[m,n] = size(y)
clean = [];

为i = 2:m-1
为j = 2:n-1
如果y(i,j)%clean添加新
clean = [干净,y(i,j)]
结束
结束
结束



我很确定这个statemetn是错误的,我不知道从这里做笏。我需要帮助写for循环来通过图像矩阵来识别黑色和白色的像素。

解决方案

尝试在您的图片上运行中值过滤器。例如

如果您为了学习原因必须使用循环,请解释您认为是坏像素(黑色?与某些邻居不同),试图根据你的标准来确定这样一个像素,并调整该像素的值。

一般来说,你不应该采用这种方法从一个空阵列开始,一次增长一个像素。相反,创建输出图像作为输入的副本( clean = noisyRGBarray; )或用零初始化( clean = zeros(size(noisyRGBarray) )),然后修改坏像素( clean(i,j,:)= ... );

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.

解决方案

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,:)=...);

这篇关于使用matlab修复像素化图像需要帮助的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆