필터 지우기
필터 지우기

Info

이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.

Cannot understand the labeled region pixel value ..

조회 수: 1 (최근 30일)
Piyum Rangana
Piyum Rangana 2017년 3월 5일
마감: MATLAB Answer Bot 2021년 8월 20일
Hi, According to the below code, I've labeled an image and by getting one label I take the pixel values out of it. The second output (That is as commented in the code itself) I cannot understand, that what kind of value it is. >> pixel (4, 29) the value is 452. Even though I analyse the pixel values of RGB channels I could not get any idea of the value. Could you please help me ?
im=imread('myImage');
im1=rgb2gray(im);
B=im2bw(im);
label=bwlabel(B);
max(max(label));
for j=5:5 %get the 5th label
[row, col] = find(label==j)
% 1st output
%row =
% 4
% 4
% 5
% 5
% 4
%col =
% 29
% 30
% 30
% 31
% 32
find(label==j) % 2nd output
%ans =
% 452
% 468
% 469
% 485
% 500
end

답변 (1개)

Sonam Gupta
Sonam Gupta 2017년 3월 8일
The output in the second case is different because you are not explicitly assigning to [row col]. Instead it is like ans = find(label == j).
If we go through documentation for function 'find' at following link http://in.mathworks.com/help/matlab/ref/find.html , we will find that for the second case, find returns a vector containing linear indices of elements in label array that have value as j. 452 is the linear index for pixel(4,29) of the label array.
It is the position of the element when you count the elements column-wise. For instance, say you have an array A as below.
A =
16 2 3 13
5 11 10 8
9 7 6 12
4 14 15 1
Linear index for 14, i.e. pixel(4,2) will be 8 whereas for 10 , i.e. pixel (2,3) it is 10.

이 질문은 마감되었습니다.

Community Treasure Hunt

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

Start Hunting!

Translated by