필터 지우기
필터 지우기

How can I threshold an image to get only one color?(red)

조회 수: 1 (최근 30일)
Serena Tenhumberg
Serena Tenhumberg 2018년 6월 26일
댓글: Serena Tenhumberg 2018년 6월 26일
my image is an Oil red O stain of a tissue and I need to remove everything but the red part of the image however this code is making the blue part almost black. Additionally I want to be able to make a slider that lets me manually adjust the threshold, sort of like in imageJ. Thanks. Here's my code so far:
clc;
clear;
close all;
% read in tiff image and convert it to double format
I=imread('NEW_tissue.tif');
% perform thresholding by logical indexing
image_thresholded =I;
image_thresholded(I>155) = 160;
image_thresholded(I<140) = 0;
% display result
figure()
subplot(1,2,1)
imshow(I,[])
title('original image')
subplot(1,2,2)
imshow(image_thresholded,[])
title('thresholded image')

답변 (1개)

Image Analyst
Image Analyst 2018년 6월 26일
Unfortunately you forgot to attach 'NEW_tissue.tif'. Anyway there already is such a function. Go to the Apps tab of the tool ribbon and run the Color Thresholder App. Load in your image, pick your color space, and start sliding away! You should be able to create a mask of all the red pixels. Or see my File Exchange where I did that in a demo.
If you have a grayscale image and want to manually and visually/interactively threshold it, see my thresholding app in my File Exchange: https://www.mathworks.com/matlabcentral/fileexchange/?term=authorid%3A31862&sort=downloads_desc
  댓글 수: 1
Serena Tenhumberg
Serena Tenhumberg 2018년 6월 26일
So if I use the app is there a way to apply the same parameters that I adjusted with one picture to a folder of pictures?

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

태그

Community Treasure Hunt

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

Start Hunting!

Translated by