How to tune threshold via slider in GUI

조회 수: 3 (최근 30일)
Nik Efe
Nik Efe 2021년 4월 25일
답변: Nik Efe 2021년 4월 25일
Hello, I have created an segmentation tool. You can choose the desired image from pc (it is send to axes1) and through the slider ,the user should manualy threshold the image (in axes2) and save the segmented image. My problem is that while I change the the value via the slider, it doesn't seperate the foreground & the background and it doesn't segement the image. It increases the brightness of the image. I would appreciate it if anyone could help.
  댓글 수: 4
DGM
DGM 2021년 4월 25일
편집: DGM 2021년 4월 25일
I can only know the code that's been shown. The code that's shown is for the slider CBF. It's adding a (which I assume is the source image) and slider value b. The result is a brighter image. If the goal is to do thresholding, then either use something like the example I gave, or im2bw(), imbinarize() or any similar process. The result of thresholding is a logical image.
For example
a = im2double(imread('spine.tif'));
b = 0.1;
cadd = a+b; % this is the same as imadd()
cge = a>=b; % simple thresholding
outpict=cat(1,a,cadd,cge); % compare
If your goal is to adjust contrast, gamma, whitepoint, blackpoint or something else that results in a non-logical image, that's a different story.
Nik Efe
Nik Efe 2021년 4월 25일
Thanks my friend, I added im2bw as you said (first step), and then I changed the min and max values from slider (from min:0 & max:255) I turned them to (min:-130 & max:130) and now, I can tune correctly the threshold via the slider.

댓글을 달려면 로그인하십시오.

채택된 답변

Nik Efe
Nik Efe 2021년 4월 25일
The answer that solved my problem suggested from @DGM is : If the goal is to do thresholding, then either use something like the example I gave, or im2bw(), imbinarize() or any similar process. The result of thresholding is a logical image.

추가 답변 (1개)

Nik Efe
Nik Efe 2021년 4월 25일
I am sorry if I didn't make the right question and showed wrong part of my code, these are my first steps with matlab. As you can see above, while the slider moves, the brightness of both foreground and background are changing. I want to tune the thresholding through the slider and not the image's brightness, any suggestions?

카테고리

Help CenterFile Exchange에서 Get Started with Image Processing Toolbox에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by