Changing Sensitivity of 'Imbinarize' using a slider
4 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Georg Edelmann
il 28 Feb 2020
Commentato: Georg Edelmann
il 3 Mar 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 Commenti
Risposta accettata
Divya Gaddipati
il 3 Mar 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!
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Red in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!