Spliting an Image into smaller images of NxN
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
I have an image of 1000x1000 pixels, I want to split the image into NxN size blocks and save them into a cell and export them into .jpe files.
0 comentarios
Respuesta aceptada
Naqi
el 5 de Nov. de 2011
1 comentario
Walter Roberson
el 5 de Nov. de 2011
You do not need to save the data in to a matrix: just write out the image directly.
imwrite(block_struct.data, FILENAME, 'jpg')
Now the only question becomes one of how to determine what filename to use.
Más respuestas (2)
Image Analyst
el 5 de Nov. de 2011
Just do this:
smallGrayImage = fullSizeGrayImage(row1:row2, col1:col2);
If it's color you can do this:
smallRGBImage = fullSizeRGBImage(row1:row2, col1:col2,:);
You'll need to set up row1, row2, col1, and col2 for each subimage with this method, but it's pretty straightforward.
0 comentarios
Walter Roberson
el 5 de Nov. de 2011
mat2cell() or blkproc() or blockproc().
You will have to decide what you want to do when N does not evenly divide 1000, leaving you with partial images.
0 comentarios
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!