Hi Folks, Slide a 5x5 window and save these window sized images in a folder.
1 view (last 30 days)
Show older comments
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
0 Comments
Accepted Answer
Walter Roberson
on 17 Oct 2016
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.
More Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!