필터 지우기
필터 지우기

Get the pixel index value of a particular area of an image

조회 수: 18 (최근 30일)
Piyum Rangana
Piyum Rangana 2017년 3월 5일
댓글: Image Analyst 2017년 3월 5일
Hi, here is my sudo code.
im=imread('myImage');
B=im2bw(im);
label=bwlabel(C);
max(max(label));
for j=1:max(max(label))
%%%%%The answer code goes here %%%%%%
end
As I mentioned in the code I am going to convert the RGB image into black and white image and then labels it.Just I want is the how to get the index value of pixels of each labeled area in to arrays separately. According to my image there are five labels and I want to get index values of pixels in each labeled areas in to five arrays. thanx !

채택된 답변

Image Analyst
Image Analyst 2017년 3월 5일
You don't need to do max(max(label)) because that just gives the number of regions, but has to scan every pixel in the image to do it, and you can get it directly from bwlabel:
[labeledImage, numberOfRegions] = bwlabel(B);
I have no idea what your "C" was.
And I don't know your definition of the "index value of each pixel". Is that the value of the labeled image at that point? Is it the (row, column) location of each non-zero pixel? Or something else? Why do you need it anyway? Why is the binary or labeled images not enough?
  댓글 수: 2
Piyum Rangana
Piyum Rangana 2017년 3월 5일
Hi sir, thanx for the answer.
The "index value of each pixel" I meant is the location of pixels(row, col) values. Actually the location of every pixels inside each label.
I need that to inpaint the labeled areas in my own algorithm using new pattern.
Anyway what I need is to get the location of the pixel values covered in each label.
thanx again !!
Image Analyst
Image Analyst 2017년 3월 5일
For example, to get the rows and columns of blob #7 of the labeled image:
[rows, columns] = find(labeledImage == 7);

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Computer Vision with Simulink에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by