How can I threshold an image to get only one color?(red)
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
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')
0 Commenti
Risposte (1)
Image Analyst
il 26 Giu 2018
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
Vedere anche
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!