How to create overlapping blocks for image processing??

1 view (last 30 days)
if true
% code
end
clc;
clear all;
I=imread('I:\project code\test1.png');
figure,imshow(I)
a=rgb2gray(I); %Converting color to grayscale
a1=imresize(a,[256,256]);
figure,imshow(a1)
impixelinfo %Get the pixel information
[r c]=size(a1);
a1=double(a1);
a1norm=a1/max(max(a1));
fun = @(x) entropy(x);
I2 = blkproc(a1norm,[2 2],[2 2],fun);
I2=I2/max(max(I2));
disp(size(I2))
figure, imshow(I2,[])
impixelinfo
fun1 = @(x) mean2(x);
I3 = blkproc(a1norm,[8 8],fun1);
I3=I3/max(max(I3));
figure;
imshow(I3,[])
impixelinfo
fun2 = @(x) std2(x);
I4 = blkproc(a1norm,[8 8],fun2);
I4=I4/max(max(I4));
figure;
imshow(I4,[])
The above program we have processed the image as non overlapping blocks. I want to know what functions or steps that can be followed to process the image using overlapping blocks.

Accepted Answer

Image Analyst
Image Analyst on 21 Oct 2012
Edited: Image Analyst on 21 Oct 2012
You can use any function you want that makes sense. In other words, a function that operates on the pixels in the block, not a function like "mcc" which would compile an m-file, or sendmail which would send an email, or some other function that doesn't make sense to use in that situation. Was there a particular function that you are worried about? By the way, you can use custom functions, not just anonymous functions, and you can use blockproc rather than the deprecated blkproc, though in your situation you would probably want to use nlfilter.
By the way, there is a conv2() function (for sliding mean), an entropyfilt() function and a stdfilt() function so you can just use those instead of doing it the way you are doing it with blkproc().
  2 Comments
Image Analyst
Image Analyst on 21 Oct 2012
Yes, they all do. But the "block" or window moves over just one pixel at a time, not in "jumps" of some distance greater than 1 like blockproc can do. But usually people want spatial operations in jumps of 1 pixels, not jumps of window width, or even less frequently, jumps of something other than 1 or the window width.

Sign in to comment.

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!