如何使用块处理图像? [英] how to use block processing for image?

查看:141
本文介绍了如何使用块处理图像?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是matlab中的新手。我试图编写一个代码,在大小为3 * 3的非重叠块中划分图像,我应该对特定块进行操作,比如获取块的中心像素的值并进行一些操作。但我不知道从哪里开始。使用像blockproc这样的命令也无济于事。任何人都可以建议我从哪里开始?

I am in kind of newbies in matlab. I am trying to write a code which divide the image in nonoverlaping blocks of size 3*3 and I am supposed to do an operation of the specific block like getting the value of the center pixel of block and do some operations. But I don't know where to start from. Using command like blockproc won't help. Can anyone suggest me where to start from?

推荐答案

您可以轻松地使用blockproc:
http://www.mathworks.com/help/toolbox/images/ref/blockproc.html

You could easily use blockproc for this: http://www.mathworks.com/help/toolbox/images/ref/blockproc.html

但如果这对您不起作用,您会得到什么错误?

But if that isn't working for you, what errors do you get?

如果你想手动完成它(比如提取每个块的中心像素的值),你可以简单地使用两个循环...但要注意,这是一个不优雅而且不是很快的方法...

If you want to do it manually (like extracting the value of the center pixel of each block) you could simply use two loops for this.. but be aware, this is rather an unelegant and not really fast way to do it...

image = imread('image.png');
s = size(image);

for i=2:3:s(1)-1
  for j=2:3:s(2)-1

    %% here you have the midpoint of each 3x3 block... 
    %% you could then easily crop the image around it if you 
    %% really need separated blocks...

  end
end

这不是一个非常快的方式......但是它有效.. 。

This isn't a really fast way though... but it works...

希望有帮助......

Hope that helps...

这篇关于如何使用块处理图像?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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