Divide image into equal parts grid and save each part

조회 수: 3 (최근 30일)
as hz
as hz 2012년 10월 24일
Hi,
I have a several images with different height and width and I want to divide them into 9 equal parts (3x3 grid) and save each part into a separate file.
Is there a simple way to do it ? Is there a function that automatically apply the grid and split the image?
Thanks a lot in advance.
PS In case I am not clear I am looking to write something similar to the TileMage Image Splitter software (<http://tilemage.50webs.com/>) without GUI.

답변 (2개)

Sean de Wolski
Sean de Wolski 2012년 10월 24일
You could use blockproc or a double for-loop with imwrite().
  댓글 수: 2
as hz
as hz 2012년 10월 24일
Blockproc looks as nice solution since my files have different height and width. I was looking on the help and tried to use block_struct.data (M-by-N, 3X3) but it does not work. Does the Blockproc automatically divide the image to 3x3?.If so I can I recall each block?
Matt J
Matt J 2012년 10월 24일
편집: Matt J 2012년 10월 24일
If you called blockproc as
blockproc(A,[3,3],fun)
then the blocks will be 3x3. I don't know what you mean by "recall each block".
I also don't think anyone understands why you are still determined to use blockproc when there is only 1 block in the image that you care about (see Sean's last comment).

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


Matt J
Matt J 2012년 10월 24일
편집: Matt J 2012년 10월 24일
You could also use MAT2TILES.
I think it's a bad idea to split the image into separate files, though. Why wouldn't it be better to keep them all in one file?
  댓글 수: 2
as hz
as hz 2012년 10월 24일
I just need the middle part and do not need the rest.
Sean de Wolski
Sean de Wolski 2012년 10월 24일
So then extract it
Icareabout = I(40:60,40:60,:) %extract a piece in the middle
If this is what you want then you should specify this in the question.

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

태그

Community Treasure Hunt

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

Start Hunting!

Translated by