Hi Folks, Slide a 5x5 window and save these window sized images in a folder.

조회 수: 1 (최근 30일)
Rao
Rao 2016년 10월 17일
댓글: Rao 2016년 10월 18일
Hi Folks, Slide a 5x5 window and save these window sized images in a folder. I have an an RGB image of 100x100, and i want to slide a window of 5x5 over this 100x100 image, and save these 5x5 window sized images as this process through out the image. We can say, i want to collect 5x5 sized images from 100x100, and window must start from left to right, and moving one pixel in between.(e.g stride = 1), and after reaching right, jump to new start position from left but one pixel below, and then continues uptill reaching bottom right corner. Also saving the position of (x,y) coordinates as it passes through the image. Lets say, 5x5 window applied on respective pixel field, save the image in a folder and its coordinates, and move ahead for new 5x5 image. And resulting is number of 5x5 images in a folder extracted form 100x100. Really appreciate if someone can help by providing any builtin function of Matlab, or some pesudo code, to do it.
Thanks

채택된 답변

Walter Roberson
Walter Roberson 2016년 10월 17일
Use blockproc with size [1 1] and 'BorderSize', [2 2] . Use a function such as
function r = save_slide(block_struct)
r = block_struct.data;
loc = block_struct.location;
filename = sprintf('save_%d_%d.png', loc); %JPEG not recommended for this!
imwrite(r, filename);
The coordinates get built into the file name.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Images에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by