getting all the nearby pixels from a center pixel in image

조회 수: 2 (최근 30일)
UTA
UTA 2013년 3월 3일
답변: Uttiya Ghosh 2020년 6월 19일
Hi everyone, I have a quick question like this: there is an image,suppose with size of 320 * 240, and I extract a center pixel position of sub-window with size 31 * 21 from this image. Now, I want to get all the pixels location of this sub-window and rearrange it as a column. Is there some fast way to do this? Thank you very much!

답변 (1개)

Uttiya Ghosh
Uttiya Ghosh 2020년 6월 19일
Hi Uta,
From my understanding, you want to convert a region of an image into a column vector. Refer to the code below:
I=imread("cameraman.tif");
subregionSize=[2 3];
subregionStartIdx=[5 6];
J=I(subregionStartIdx(1):subregionStartIdx(1)+subregionSize(1)-1,...
subregionStartIdx(2):subregionStartIdx(2)+subregionSize(2)-1);
JCol=reshape(J,prod(subregionSize),1);
You will receive the required Column Vector in JCol. You can change the sizes as per your requirements.
For more information, refer to the links below:

카테고리

Help CenterFile Exchange에서 Images에 대해 자세히 알아보기

태그

아직 태그를 입력하지 않았습니다.

Community Treasure Hunt

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

Start Hunting!

Translated by