Unable to perform assignment because the induces on the left side are not compatible with the size of the right side

1 vue (au cours des 30 derniers jours)
I am working on fingerprint minutiae algorithm and i get this error when i work on some fingerprint images. the error says Unable to perform assignment because the size of the left side is 1-by-1 and the size of the right side is 2-by-2 and this is my code which concerned with the error :
for ind=1:length(CentroidTermX)
Klocal=K(CentroidTermY(ind)-2:CentroidTermY(ind)+2,CentroidTermX(ind)-2:CentroidTermX(ind)+2);
Klocal(2:end-1,2:end-1)=0;
[i,j]=find(Klocal);
OrientationTerm(ind,1)=Table(i,j);
end
dxTerm=sin(OrientationTerm)*5;
dyTerm=cos(OrientationTerm)*5;
figure
imshow(K)
this part of code which find the orientation of the termination

Réponse acceptée

Walter Roberson
Walter Roberson le 23 Sep 2018
You extract
Klocal=K(CentroidTermY(ind)-2:CentroidTermY(ind)+2,CentroidTermX(ind)-2:CentroidTermX(ind)+2);
Klocal(2:end-1,2:end-1)=0;
so Klocal is extracted as an array with 5 rows and 5 columns, and you then zero out the lower right hand side. That leaves the top row and left column as being potentially non-zero -- Klocal(1,:) and Klocal(:,1) might be non-zero, a total of 9 different locations that are potentially non-zero.
[i,j]=find(Klocal);
That asks for the location of all of the non-zero values in the 5 x 5 array that resulted above. With 9 different locations that were not explicitly 0, you could get anywhere between 0 and 9 results. The i and j are going to be returned as column vectors in this case.
OrientationTerm(ind,1)=Table(i,j);
With ind being scalar and 1 being scalar, the left hand side names exactly one output location. The right hand side, on the other hand, names either 0, 1, 4, 9, 16, 25, 36, 49, 64, or 81 locations in Table, because when you index with two vectors of values, the output corresponds to taking all combinations of indices.
If you wanted to pull corresponding individual entries out of Table instead of rows and columns, you would use
temp = Table( sub2ind(size(Table), i, j) );
sub2ind would take those column vectors of indices and create individual indices from each corresponding row, so the above would end up designating 0 through 9 output locations.
You would then have to figure out how you wanted to store the 0 through 9 entries into OrientationTerm
Perhaps what you want is
[i,j] = find(Klocal, 1);
if ~isempty(i)
OrientationTerm(ind,1) = Table(i,j);
else
OrientationTerm(ind,1) = nan;
end
This finds one of the non-zero entries, tending with it tending to prefer to take from the first column (that you did not zero out) before it would take from the rest of the first row, because of the order that arrays are scanned.
  1 commentaire
Mahmoud Hassan
Mahmoud Hassan le 25 Sep 2018
that was brilliant bro ... you have understood it much better than if i was explaining to you what i am doing! thank you so much

Connectez-vous pour commenter.

Plus de réponses (1)

Image Analyst
Image Analyst le 23 Sep 2018
Evidently the (badly-named) i and j are vectors, not single numbers.
If you had remembered to attach your variables in a .mat file, we could have done more for you.
  4 commentaires
Mahmoud Hassan
Mahmoud Hassan le 23 Sep 2018
actually i don't understand what you are trying to tell me ... how would this save help to solve the error?!
Walter Roberson
Walter Roberson le 23 Sep 2018
Saving the file and attaching it would allow other people to examine your variables and test your code.

Connectez-vous pour commenter.

Catégories

En savoir plus sur Convert Image Type dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by