필터 지우기
필터 지우기

indices of intersection points of two logical arrays

조회 수: 19 (최근 30일)
Amani
Amani 2013년 1월 18일
댓글: Azzi Abdelmalek 2013년 11월 10일
how can I find the indices of the intersection points of a binary image with a logical array
this is the code
//////////////////
f2= imread('anyBinaryImage');
norm2 = normalization(f2,128,128); % normalization function
f3= zeros(size(norm2));
a = ones(2,80);
f3(10:11,1:80) = a;
[g, k, c]= intersect(norm2,f3,'rows');
////////////////
but I got empty matrix, even though there are lots of intersection points between the image and the array
g =
Empty matrix: 0-by-128
k =
Empty matrix: 0-by-1
c =
Empty matrix: 0-by-1
what should I do ?
  댓글 수: 3
Walter Roberson
Walter Roberson 2013년 1월 19일
The f3 you construct is not a logical array. zeros() and ones() create numeric arrays, not logical arrays. Initialize with false(size(norm2)) instead of zeros()
Amani
Amani 2013년 1월 21일
thank you soooooo much for clarifying

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

채택된 답변

Image Analyst
Image Analyst 2013년 1월 19일
Try it this way:
% Find pixels in both binary images:
intersectionImage = f2 & f3;
% Now get the rows and columns of the intersecting pixels
% (for some unknown, unspecified, and probably unnecessary reason):
[rows columns] = find(intersectionImage);
Are you sure you really need the rows and columns of the intersections? I'd say that most likely you don't need them at all. The intersectionImage is enough to do whatever you're going to do.
  댓글 수: 2
Amani
Amani 2013년 1월 21일
thank you very much , it works I'm working on handwriting recognition, so I'm trying to find the intersections with the baseline
Azzi Abdelmalek
Azzi Abdelmalek 2013년 11월 10일
Amani, When the answer helps, you have to click on [accept this answer]. Now, I did it at your place

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

추가 답변 (0개)

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by