Splitting Images?

조회 수: 5 (최근 30일)
Jason
Jason 2011년 6월 22일
Hi, I have a question here.
Take for example an image of size n by m. What I want is to split the images into 4 similar quadrants as follows: http://www.flickr.com/photos/jokerzy89/5859808219/ Next, I want to swap the following. (1)A and C (2) B and D, then display the final result as a new image.
Can someone please help? Thank you!
  댓글 수: 4
Jason
Jason 2011년 6월 22일
Thank you, that is why the floor function comes into picture.
Sean de Wolski
Sean de Wolski 2011년 6월 22일
yes, you could also use ceil.

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

채택된 답변

Sean de Wolski
Sean de Wolski 2011년 6월 22일
swap1324 = @(x)([x((floor(size(x,1)/2)+1):end,(floor(size(x,2)/2)+1):end) x((floor(size(x,1)/2)+1):end,1:floor(size(x,2)/2)); x(1:floor(size(x,1)/2),(floor(size(x,1)/2)+1):end) x(1:floor(size(x,1)/2),1:floor(size(x,2)/2))]);
I = imread('cameraman.tif'); %sample image
I2 = swap1324(I);
imtool(I2)
Obviously the above should be broken down into it's own function that doesn't have to repeat the function floor(size(stuff))) over and over again.
  댓글 수: 1
Jason
Jason 2011년 6월 22일
That was fast, and it was exactly what I needed, thank you, Sean!

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

추가 답변 (0개)

Community Treasure Hunt

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

Start Hunting!

Translated by