Messagebox warning in matlab
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
marie lasz
el 24 de Sept. de 2020
Respondida: Image Analyst
el 25 de Sept. de 2020
hello everyone,
I am running this code and getting warning that text is too long for a messagebox. I set breakpoints and at message it is giving different values and showing messagebox without text. What am I doing wrong here?
code is given below;
close all
clc
workspace;
im = imread('lena.bmp')
Image1= im;
im2 = imread('lena2.bmp')
Image2= im2;
NCC = normxcorr2(Image1,Image2);
message = sprintf('The normalized cross correlation is %.2f.', NCC);
msgbox(message);
0 comentarios
Respuesta aceptada
Peter O
el 24 de Sept. de 2020
The NCC return value you're getting back is a matrix of correlation values (for Lena, it's 512x512). The string you're passing to messagebox will print that text 262,144 times (one for each value in the matrix), so yes, it gets pretty big!
Are you looking for the max correlation? If so, just wrap:
maxcorr = max(NCC(:)); % Single max across all
message = sprintf('The max normalized cross correlation is %.2f.', maxcorr);
msgbox(message);
If you're interested in a pattern or more than a single quantity, it might be easier to view it as a 3D surface plot. See the worked example here: https://www.mathworks.com/help/images/ref/normxcorr2.html
5 comentarios
Peter O
el 25 de Sept. de 2020
That's correct, it's the one max value which is friendlier to the message box. You could also use mean(NCC(:)) if you wanted the average of the entire matrix.
Más respuestas (1)
Image Analyst
el 25 de Sept. de 2020
Get rid of the message and use imshow():
imshow(NCC, []);
0 comentarios
Ver también
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!