필터 지우기
필터 지우기

Image patch extraction from given co-ordinate

조회 수: 1 (최근 30일)
MD RESHAD UL HOQUE
MD RESHAD UL HOQUE 2018년 1월 25일
편집: Rik 2018년 1월 29일
Hello everyone, I have an image [800 x 900 x 4]. I have to extract patches with a center point [(x1,y1),(x2,y2)... ]. How can I do that ?.
Thanks
  댓글 수: 2
Rik
Rik 2018년 1월 25일
What size should those patches be? And is your image a 3D gray scale image, or some other format? (YMCK perhaps?)
MD RESHAD UL HOQUE
MD RESHAD UL HOQUE 2018년 1월 25일
Patches size 17 x 17. It is 4D image.

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

채택된 답변

Rik
Rik 2018년 1월 25일
편집: Rik 2018년 1월 29일
Your image is not 4D. It has 3 dimensions, unless what you posted in your question is not true.
patch{i}=IM(x(i)+[-8 8],y(i)+[-8 8],:);
This makes use of the quirk of Matlab that if you enter corner coordinates, it will return the entire square part.
For edge cases, the code below crops the part outside of the matrix (my comment below has a copy-and-past bug)
selected_patches = cell(length(x),1);
for i=1:length(x)
xtemp=x(i)+[-8 8];
xtemp(xtemp<1)=1;xtemp(xtemp>size(IM,1))=size(IM,1);
ytemp=y(i)+[-8 8];
ytemp(ytemp<1)=1;ytemp(ytemp>size(IM,2))=size(IM,2);
selected_patches{i}=IM(xtemp,ytemp,:);
end
  댓글 수: 8
MD RESHAD UL HOQUE
MD RESHAD UL HOQUE 2018년 1월 25일
편집: Walter Roberson 2018년 1월 25일
In that case, patch initialization will be like this or different :
patch=zeros(length(x),2);
or
Patch=[];
Pardon me I am new in matlab.
Thanks
Walter Roberson
Walter Roberson 2018년 1월 25일
patch = cell(length(x),1);

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Lighting, Transparency, and Shading에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by