image the same and different
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
lol lolol
am 10 Sep. 2019
Kommentiert: lol lolol
am 10 Sep. 2019
I have a function:
function [transformed, image] = transformImage(host,transformMatrix)
host=im2double(host);
imageR=transformMatrix * host(:,:,1)*transformMatrix;
imageG=transformMatrix * host(:,:,2)*transformMatrix;
imageB=transformMatrix * host(:,:,3)*transformMatrix;
transformed(:,:,1)=imageR;
transformed(:,:,2)=imageG;
transformed(:,:,3)=imageB;
image = transformed;
transformed = im2uint8(image);
if transformed==im2uint8(image)
disp("1. true")
else
disp("1. false")
end
end
and main:
[image, transformedImage] = transformImage(host, transformMatrix);
if transformedImage==im2uint8(image)
disp("2.true")
else
disp("2.false")
end
and result is:
1. true
2.false
why inside function is tthe same, and outside is different?
0 Kommentare
Akzeptierte Antwort
Stephen23
am 10 Sep. 2019
Bearbeitet: Stephen23
am 10 Sep. 2019
You swapped the order of the output arguments when you called the function.
Here is the function definition:
function [transformed, image] = transformImage(...)
But here is how you called the function:
[image, transformedImage] = transformImage(...)
MATLAB has positional input/output arguments. Their names are totally irrelevant.
You swapped the order, so you got the uint8 image in image (the 1st output) and the double image in transformedImage (the 2nd output). Then you converted the uint8 image into a uint8 image (doing nothing whatsoever) and compared that to the double image.
Weitere Antworten (0)
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!