Changing Sensitivity of 'Imbinarize' using a slider
5 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Georg Edelmann
el 28 de Feb. de 2020
Comentada: Georg Edelmann
el 3 de Mzo. de 2020
Hey guys,
I´m binarizing Images using Matlab and try to figure out the right sensitivity value for each image. Therefore a slider would be quite useful.
How could this be done?
Here is my code so far.
clf()
I= imread('Bild_1.jpg'); %input
I=I(:,:,1); %Selecting a colour
I = imbinarize(I,'adaptive','ForegroundPolarity','dark','Sensitivity',sens); %turn grayscale image in binary image
%sens is my variable
imshow(I);
fig = uifigure();
fig.Position([3,4]) = [400,75];
sld = uislider(fig,'Position',[50,50,300,50],'Value',1,'Limits',[0,1],...
'ValueChangedFcn', @(sld,event)changeSensitivityFcn(sld,event));
function changeSensitivityFcn(sld, event)
sens=sld.Value
drawnow()
end
I hope you can help me.
Greetings
Here is a related question i asked about the sliders
0 comentarios
Respuesta aceptada
Divya Gaddipati
el 3 de Mzo. de 2020
You can store the figure handle in a variable using uiaxes which can be passed to the changeSensitivity function to modify the binarization according to the changed sensitivity factor.
You can modify your code to something similar to as the following:
clc; clear; close all;
I= imread('peppers.png'); %input
I = I(:,:,1); %Selecting a colour
fig = uifigure;
cg = uiaxes(fig, 'Position', [50, 70, 500, 300]);
imshow(I, 'parent', cg);
sld = uislider(fig, 'Position', [100 50 300 50], 'Value', 1, 'Limits', [0,1],...
'ValueChangedFcn', @(sld, event)changeSensitivityFcn(event, cg, I));
function changeSensitivityFcn(event, cg, I)
sens = event.Value;
cg.Children.CData = im2uint8(imbinarize(I, 'adaptive', 'ForegroundPolarity', 'dark', ...
'Sensitivity', sens));
drawnow();
end
Hope this helps!
Más respuestas (0)
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!