If there is a 512*512 image which has to be sampled into 16*16 image patches?how

조회 수: 3 (최근 30일)
If there is a 512*512 image which has to be sampled into 16*16 image patches,how can I do that?
  댓글 수: 3
hamed abdulaziz
hamed abdulaziz 2013년 12월 31일
편집: hamed abdulaziz 2013년 12월 31일
Sorry,I did not see your previous answer on my question ,I tried this :
I = imread('d:\3.bmp');
I=imresize(I,[512 512]);
patch_cell = mat2cell( 8*ones(1,size(I,1)/8), 8*ones(1,size(I,2)/8), size(I,3) );
but I have this error
Error using mat2cell (line 107) Input arguments, D1 through D2, must sum to each dimension of the input matrix size, [1 64].'
Error in patchs (line 6) patch_cell = mat2cell( 8*ones(1,size(I,1)/8), 8*ones(1,size(I,2)/8), size(I,3) );
hamed abdulaziz
hamed abdulaziz 2013년 12월 31일
Please could you guide me to correct these errors?

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

채택된 답변

Matt J
Matt J 2014년 1월 1일
편집: Matt J 2014년 1월 1일
Using MAT2TILES
patches = mat2tiles(YourImage,[16,16]);
  댓글 수: 4
hamed abdulaziz
hamed abdulaziz 2014년 1월 1일
How can I show the shapes of patches to see the them?
Image Analyst
Image Analyst 2014년 1월 1일
The shapes are rectangles. Do you mean you want to see where the rectangles are, say in lines superimposed over the original image where the patches were extracted from? Or do you want to see every patch as a separate sub image like the FAQ does?

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

추가 답변 (3개)

Image Analyst
Image Analyst 2013년 12월 31일
편집: Image Analyst 2014년 1월 1일
It does it two different ways. One using mat2cell(), and one using just simple indexing. It's a full blown demo with sample images and display of each sub-image that it extracted so you can see what it did.

Jan
Jan 2013년 12월 31일
The easiest way would be to let two FOR loops crop the parts from the original array. The details depend on what you want as output.
  댓글 수: 1
hamed abdulaziz
hamed abdulaziz 2013년 12월 31일
Thank you Mr.Jan,I would like to use this code
patch_cell = mat2cell( 8*ones(1,size(I,1)/8), 8*ones(1,size(I,2)/8), size(I,3) );
but I got these error
Error using mat2cell (line 107) Input arguments, D1 through D2, must sum to each dimension of the input matrix size, [1 64].'
Error in patchs (line 6) patch_cell = mat2cell( 8*ones(1,size(I,1)/8), 8*ones(1,size(I,2)/8), size(I,3) );
Please could you guide me to correct it?

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


Walter Roberson
Walter Roberson 2013년 12월 31일
patch_cell = mat2cell( I, 16*ones(1,size(I,1)/16), 16*ones(1,size(I,2)/16), size(I,3) );

카테고리

Help CenterFile Exchange에서 Image Filtering and Enhancement에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by