How to create sub images of a main image?
6 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Hi everyone,
I need to create and save images of a main image. My resolution of my main image is 1024x2048 and I have to save images of 256x256 of all array (main image), so I have to go through the entire array and save images of 256x256 consecutively
Does anybody Know how to do that?
Thanks everyone:)
0 Kommentare
Antworten (1)
Guillaume
am 17 Mai 2019
%inputs:
%img: a full colour (3D), or greyscale image (2D)
%blocksize: a 2-element vector giving the height and width of each block
%
%precondition: the image size is a multiple of blocksize
assert(all(mod([size(img, 1); size(img, 2)], blocksize(:)) == 0), 'size of image is not a multiple of blocksize');
numblocks = [size(img, 1); size(img, 2)] ./ blocksize(:);
subimages = mat2cell(img, ones(1, numblocks(1)) * blocksize(1), ones(1, numblocks(2)) * blocksize(2), size(img, 3));
subimages is a cell array containing each 256x256 block. You can then save these in a loop. mat2cell is the function that does the extraction of each block.
0 Kommentare
Siehe auch
Kategorien
Mehr zu Graphics Performance finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!