Spliting an Image into smaller images of NxN

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.

 채택된 답변

Naqi
Naqi 2011년 11월 5일

0 개 추천

I tried using blockproc(), but could not save block_struct.data into a matrix. I want to be able to export the images into .jpg files.

댓글 수: 1

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.

댓글을 달려면 로그인하십시오.

추가 답변 (2개)

Image Analyst
Image Analyst 2011년 11월 5일

1 개 추천

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.
Walter Roberson
Walter Roberson 2011년 11월 5일

0 개 추천

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.

질문:

2011년 11월 5일

Community Treasure Hunt

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

Start Hunting!

Translated by