i want to extract fluorescent marked text from an image and convert the extracted image to another image file. how do i do that? i am new to matlab.
Mostra commenti meno recenti

i plan to extract the marked text..please provide the code
Risposta accettata
Più risposte (2)
Bruno Pop-Stefanov
il 22 Gen 2014
Modificato: Bruno Pop-Stefanov
il 22 Gen 2014
1. Use a color segmentation algorithm to generate a mask where white pixels correspond to the yellow highlights in your input image. To do that you can:
- Take a look at tutorials that Image Analyst has written on the File Exchange.
- Convert the image into HSV space and manually define thresholds around the yellow highlight color to extract yellow pixels.
- Take a look at a tutorial here.
2. Once you have a binary mask, fill the holes left by back letters using imfill. That will give you solid blocks of white pixels on a black background.
3. "Crop" the highlighted text from your input image using that mask. The mask will be a black and white image with 1 channel, but your input image is RGB (3 channels). You can execute the following to perform that operation:
% First, convert B&W mask to RGB
% mask_bw has size (n x m x 1)
% mask_rgb will have size (n x m x 3)
mask_rgb = repmat(mask_bw,1,1,3);
% Then, the mask indicates the location of pixels in your ROI
% Use it to change the color of other pixels to white
% in_img is your input image and has size (n x m x 3)
out_img = in_img;
out_img(~mask_rgb) = 1;
4 Commenti
ANAND SARIT
il 22 Gen 2014
Bruno Pop-Stefanov
il 22 Gen 2014
Take a look at the code here:
Open SimpleColorDetectionByHue.m, go to lines 226-231 and change the values to the following:
hueThresholdLow = 0.10;
hueThresholdHigh = 0.20;
saturationThresholdLow = 0.8;
saturationThresholdHigh = 1.0;
valueThresholdLow = 0.8;
valueThresholdHigh = 1.0;
They should work for your image.
Then, run the function by executing SimpleColorDetectionByHue in the Command Window and, when asked, choose to provide your own image (anand.png).
See the steps of the algorithm in action. Then, close the window and go back to the source code to see how it is done.
The steps are basically:
- Convert RGB image to HSV
- Apply lower and upper thresholds in HSV space
- Get combined mask
- Remove components that are too small from the mask with bwareaopen
- Smooth mask border with morphological closing using imclose
- Fill holes in the mask with imfill
- Apply mask to original RGB image
You can search for functions you don't know in the documentation to help you understand. Play around with the different parameters -- like the size of the structural element used in morphological closing, for example -- to get the result you want.
Sony s
il 30 Ott 2017
please let me know what will be the values of hueThresholdLow, hueThresholdHigh , saturationThresholdLow , saturationThresholdHigh , valueThresholdLow, valueThresholdHigh , these parameters for brown color, black color magenda color
Image Analyst
il 30 Ott 2017
Depends on your image. See the Color Thresholder app on the Apps tab of the tool ribbon.
ANAND SARIT
il 24 Gen 2014
0 voti
2 Commenti
Image Analyst
il 24 Gen 2014
Modificato: Image Analyst
il 24 Gen 2014
Not sure what you mean? Do you want the bounding box of the yellow regions cropped out into separate images? Just like the original (black text on yellow background), but cropped? If the yellow "Pure" yellow, in other words, r=255, G=255, and B = 0?
ANAND SARIT
il 25 Gen 2014
Categorie
Scopri di più su Image Processing Toolbox in Centro assistenza e File Exchange
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

