Assignment has more non-singleton rhs dimensions than non-singleton subscripts
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
My program get an error "Assignment has more non-singleton rhs dimensions than non-singleton subscripts" in line 21, which is "S (i, j, k) = Temp;" but I do not know how to fix it. My program is shown below:
function J = EE4206_Assignment3_Q1_StretchContrast (filename, MinGray, MaxGray)
A = filename;
I = imread (A);
I = im2double(I)*255;
[r c k] = size (I);
MinInput = min(min(I));
MaxInput = max(max(I));
S = ones (r, c, 3);
for i = 1 :r
for j = 1 : c
for k = 1 :3
Temp = (MaxGray - MinGray).*(I(i, j, k) - MinInput)./(MaxInput - MinInput) + MinGray;
S (i, j, k) = Temp;
end
end
end
J = image (S);
imshow (J);
Thank you !!!
0 commentaires
Réponses (2)
Matt Fig
le 23 Oct 2012
Modifié(e) : Matt Fig
le 23 Oct 2012
Please do not use this awful construct to find the global minimum:
MinInput = min(min(I)); % This is the cause of your problem.
MaxInput = max(max(I));
Use this instead:
MinInput = min(I(:));% Global min no matter how many dims!
MaxInput = max(I(:));
(What you would have had to do is call MIN a third time...)
0 commentaires
Walter Roberson
le 23 Oct 2012
You are assuming that imread() is returning a 3D array (you index it that way), but you are only applying two levels of max() and min() so you are going to be getting vector results for max() and min().
I suggest you recode
MinInput = min(I(:));
MaxInput = max(I(:));
0 commentaires
Voir également
Catégories
En savoir plus sur C4ISR 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!