简体   繁体   中英

Matlab image processing

I have put a sliding window over my image. If the mean intensity in the window is below 200 then i need to discard this window and combine all the windows with mean intensity above 200.

Can anyone explain to me how to combine certain windows in an image? I have tried cropping each of the windows with intensity above 200 but am really unsure of where to go from here. Cant find any links or help online.

In the if statement , is it possible to just create a new image matrix and add the cropped image to it? For eg

%for loop for sliding window code here 

  if (average>200) 
   windowCrop=imcrop(imgWindow);
   imgNew=windowCrop + windowCrop

  end %end if 
end %end for 

Thank you

Use im2col with sliding option to get the blocks, do thresholding to set blocks of mean below 200 to zero, then combine all.

The code can be something like this:

A=imread('cameraman.tif');BlockDim=[8 8];

B=im2col(double(A),BlockDim,'sliding');

ValidBlockIndices=find(mean(B)>200); TotalBlockSum=zeros(prod(BlockDim),1);

for i=ValidBlockIndices TotalBlockSum=TotalBlockSum+B(:,i); end;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM