开发者

how to use block processing for image?

I am in kind of newbies in mat开发者_StackOverflowlab. 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?


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...

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜