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

发布于 2024-11-07 02:49:02 字数 185 浏览 0 评论 0原文

因此,我用四个量化值量化了灰度图像。我试图保留量化图像每行的第一个像素,并用其左侧像素的差值替换每个连续像素。

你会如何在 matlab 中对此进行编码?有人可以从概念上向我解释一下吗?

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

So, I've quantized a grayscale image with four quantized values. I'm trying to maintain the first pixel of each row of the quantized image and replace each successive pixel with the difference from the pixel to its left.

How would you code this in matlab and can someone explain this to me conceptually?

Also, my concern is that because the image is relatively uniform because of the quantization of the dynamic range, most of the image would appear black, no? It seems to me that only the transition areas and the edges will have some difference in quantized values.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

成熟稳重的好男人 2024-11-14 02:49:02

要创建与左侧像素的差异,您所要做的就是从第 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)];

是的,您会期望有相当多的像素均匀的补丁(它将是灰色的,因为除非你绘制差异的绝对值,否则会有一些是负的)。

To create the difference to the pixel on the left, all you have to do is subtract the pixels in columns 1,2,3... from the columns 2,3,4...

%# 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)];

Yes, you'd expect quite a few uniform patches (which will be gray, since unless you plot the absolute value of the differences, there will be some that are negative).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文