How to represent the value of X and Y Pixels in array of Two Dimensions using Matlab
이 질문을 팔로우합니다.
- 팔로우하는 게시물 피드에서 업데이트를 확인할 수 있습니다.
- 정보 수신 기본 설정에 따라 이메일을 받을 수 있습니다.
오류 발생
페이지가 변경되었기 때문에 동작을 완료할 수 없습니다. 업데이트된 상태를 보려면 페이지를 다시 불러오십시오.
이전 댓글 표시
Hi , Suppose if this is my image

I need to find the x, y coordinates of white pixels in image. I am getting the value of x and y coordinates separately one after the other, i want to represent it in 2 dimensional array matrix like [x,y] ,how can i represent it in 2 D matrix?
Then i need to calculate the farthest distance in that box ? how to solve this?
채택된 답변
The provided answer is correct, you only need some processing steps, the image contains white borders , you need to crop it using some software, after that, you need to convert into grayscale and then to double instead of unit8 :
X=rgb2gray(X);
X=im2double(X);
% then the command provided above.
댓글 수: 12
Thank You Youssef khmou ,
Actually this image i have converted to gray then applied threshold , then edge detection, this image is the output after edge detection .
Using 'find' i am getting x and y coordinates , how to represent it in matrix??
Not a square matrix but a very thin matrix :
[y, x] = find(binaryImage);
M=[y,x];
Thank you so much....
Now i need to calculate the distance between those coordinates , this can be done by using distance formula. But i need to compare each coordinate with all other coordinate in matrix, then find the farthest distance between them.
like [x1,y1] with [x2,y2],, in next iteration [x1,y1] with [x3,y3] and so on till [xn,yn].
Similarly [x2,y2] with all other coordinates in matrix.
Suppose the matrix you obtained is M :
N=length(M);
The euclidean distances form a matrix of dimensions NxN where the diagonal elements are 0, you can basically use two dimensional loop :
D=zeros(N);
for x=1:N
for y=1:N
D(x,y)=sqrt((M(x,1)-M(y,1))^2-(M(x,2)-M(y,2))^2);
end
end
Its not working out...
this is my program where a(i,j) is my image
count=1;
for(i=1:x)
for(j=1:y)
if a(i,j)~=1;
x(count)=j;
y(count)=i;
x(1,:)= x(count);
y(:,1)= y(count);
count=count+1;
a(i,j) = sqrt((y(count)-y(:,1))^2 + (x(count)-x(1,:))^2);
end;
end;
end;
[x,y]=find(a);
xy=[x,y]
My problem is i want to store the value of x(count) and y(count) in some temporary variable. How to assign the value ???
here i have used x(1:,) and y(:,1)
but i am getting error
"Index exceeds matrix dimensions "
I tried the the loop i proposed and it is working, try to verify your program .
I tried out your program..
i am not getting any answer...
and i have a doubt... why ur using 'zeros', coz i need to find pixel values with ones... and my image is not a square matrix.. its MxN
earlier after obtaining the matrix M of coordinates of white pixels, you wanted to calculate the distance between each point M(x,y) and the rest of the points, the two dimensional loop works,zeros is a variable initialization :
for x=1:N
for y=1:N
D(x,y)=sqrt((M(x,1)-M(y,1))^2-(M(x,2)-M(y,2))^2);
end
end
The diagonal is zero because it is a distance between a point M(x,y) and itself.
ok, but i am not getting any result...
can you provide me your code.....
And in my code , is this statement correct....??
x(1,:)= x(count);
y(:,1)= y(count);
actually i am getting error at this line...
x(1,:) means the x,y coordinates of the 1st point, but y(:,1) is the x coordinates of all points, that is where you get the error, the distance between the x and y points is sqrt((M(x,1)-M(y,1))^2-(M(x,2)-M(y,2))^2)
k attach me your complete code ,,, ill just try
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Image Filtering and Enhancement에 대해 자세히 알아보기
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!웹사이트 선택
번역된 콘텐츠를 보고 지역별 이벤트와 혜택을 살펴보려면 웹사이트를 선택하십시오. 현재 계신 지역에 따라 다음 웹사이트를 권장합니다:
또한 다음 목록에서 웹사이트를 선택하실 수도 있습니다.
사이트 성능 최적화 방법
최고의 사이트 성능을 위해 중국 사이트(중국어 또는 영어)를 선택하십시오. 현재 계신 지역에서는 다른 국가의 MathWorks 사이트 방문이 최적화되지 않았습니다.
미주
- América Latina (Español)
- Canada (English)
- United States (English)
유럽
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
