Matlab - 用左边的像素替换连续的像素

时间:2011-05-13 01:36:21

标签: matlab

所以,我用四个量化值量化了灰度图像。我正在尝试维护量化图像每行的第一个像素,并用与左边像素的差异替换每个连续的像素。

你会如何在matlab中编写代码?有人可以从概念上向我解释这个吗?

另外,我担心的是,由于动态范围的量化,图像相对均匀,因此大部分图像看起来都是黑色的,不是吗?在我看来,只有过渡区域和边缘在量化值上会有一些差异。

1 个答案:

答案 0 :(得分:3)

要创建左边像素的差异,您只需要从2,3,4列中减去1,2,3行中的像素......

%# create a random image with four values
randomImage = randi(4,[100,90]); %# use different numbers of rows and cols so we know which is which

%# catenate the first column of the image with the difference from the pixel to the left
%# for all pairs of columns in the image
differenceImage = [randomImage(:,1),randomImage(:,1:end-1)-randomImage(:,2:end)];

是的,你会期待相当多的统一补丁(这将是灰色的,因为除非你绘制差异的绝对值,否则会有一些是负的)。

相关问题