imcontrast Data range vs Display range

3 visualizaciones (últimos 30 días)
Mohamed Amine Henchir
Mohamed Amine Henchir el 21 de Nov. de 2018
I'm using imcontrast to interactively select the best min and max values for the histogram adjustment, with certain pictures I get this error contrast_error.PNG
it's basically saying that the data range and the diplay range are somehow mismatched and need to be changed, so after I do the selection and I'm satisfy with the results and when I close the window(I have a function that extract max and min values from imcontrast once the user closes the window) and the image goes completely black, because apperently the numbers that I'm getting from imcontrast are the ones changed for the display issue.
any Idea on what to do to fix this?
here is my code
function adjust_contrast_Callback(hObject, eventdata, handles)
global icontrast;
guidata(hObject, handles);
axes(handles.axes1);
h = imshow(handles.I);
dbh = imcontrast(h);
total = str2double(get(findobj(dbh, 'tag', 'window max edit'), 'String'));
disp(total);
set(dbh, 'CloseRequestFcn', @(s,e)getValues(s))
waitfor(dbh);
icontrast(1) = icontrast(1)/total;
icontrast(2) = icontrast(2)/total;
disp(icontrast);
handles.I = imadjust(handles.I,icontrast);
imshow(handles.I);
guidata(handles.figure1,handles);
h = datacursormode;
set(h,'DisplayStyle','datatip',...
'SnapToDataVertex','off','Enable','on')
function getValues(dbh)
global icontrast;
window_min = str2double(get(findobj(dbh, 'tag', 'window min edit'), 'String'));
window_max = str2double(get(findobj(dbh, 'tag', 'window max edit'), 'String'));
icontrast = [window_min window_max];
disp(icontrast);
delete(gcf);
I'm also using icontrast here as a global variable which is not good practice, but it was because I couldn't figure out how to pass variables between that function and any other callback function, if you have an idea on how to do it, that would also be nice!
thank you!

Respuestas (0)

Community Treasure Hunt

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

Start Hunting!

Translated by