Error of Display Image that has highest psnr value in exe file but not in matlab file

1 view (last 30 days)
This is a code for push button to display image that have highest performance value based on psnr. So, I have make if else statement to display the best of image enhancement. The problem was, when I execute file in .exe its not display the image but in matlab file its display with no error
% --- Executes on button press in pushbutton22.
function pushbutton22_Callback(hObject, eventdata, handles)%bestresult
global ori
global ret
global retinex
global L
global Ihsv
global J
global BInv
global BImp
global peaksnrretinex
global peaksnrclahe
global peaksnrlowlight
global B
global gretinex
global gclahe
global glowlight
%retinex
L = max(ori, [], 3);
ret = MSRetinex2(mat2gray(L), [5, 35, 350], [5 5], 8);
Ihsv = rgb2hsv(ori);
Ihsv(:, :, 3) = mat2gray(ret);
retinex = hsv2rgb(Ihsv);
imshow(retinex,'Parent',handles.axes2);
gretinex = imnoise(retinex, 'salt & pepper', 0.02);
%clahe
ch = im2uint8(ori);
ch = rgb2gray(ori);
J = adapthisteq(ch,'clipLimit',0.02,'Distribution','rayleigh');
imshow(J,'Parent',handles.axes8);
gclahe = imnoise(J, 'salt & pepper', 0.02);
%low-light
% AInv = imcomplement(ch);
BInv = imreducehaze(ori);
B = imcomplement(BInv);
BInv = imreducehaze(ori, 'Method','approx','ContrastEnhancement','boost');
BImp = imcomplement(BInv);
imshow(BImp,'Parent',handles.axes9);
glowlight = imnoise(BImp, 'salt & pepper', 0.02);
%psnr
peaksnrretinex = psnr(gretinex,retinex);
set(handles.edit8, 'String', peaksnrretinex);
peaksnrclahe=psnr(gclahe,J);
set(handles.edit11, 'String', peaksnrclahe);
peaksnrlowlight = psnr(glowlight,BImp);
set(handles.edit14, 'String', peaksnrlowlight);
A = [peaksnrretinex,peaksnrclahe,peaksnrlowlight];
B = max(A);
if peaksnrretinex == B
imshow (retinex);
elseif peaksnrclahe == B
imshow (J);
elseif peaksnrlowlight == B
imshow(parent, BImp);
else
display "error";
end
  3 Comments
Rik
Rik on 30 Apr 2021
15 global variables and 4 words worth of comments. How do you expect people to understand what you want to do? Why are you using global variables with such short names?
What you can do is to set a value to a uicontrol text box. That way you can keep track of which lines are executed without the debugging tools being available.

Sign in to comment.

Answers (0)

Products


Release

R2019a

Community Treasure Hunt

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

Start Hunting!