Azzera filtri
Azzera filtri

how to crop the red region in an image

4 visualizzazioni (ultimi 30 giorni)
I have a mammogram image and in it a red contour, the rgb channels across this contour are changed whereas they are constant all over the other regions. I want to do a for loop to search about this region in the image and crop it. Can anyone help?

Risposta accettata

Image Analyst
Image Analyst il 11 Giu 2017
I'm guessing that it's a mammogram that's had computer graphics (red pixels) burned into the image. To find the pure red pixels, you need to find where the red signal is 255 or 65535, depending on whether it's uint8 or uint16, and the green and blue signals are 0. See this snippet:
% Find pure red pixels, pure green pixels, and pure blue pixels.
maxValue = intmax(class(rgbImage))
pureRedPixels = (redChannel == maxValue) & (greenChannel == 0) & (blueChannel == 0);
pureGreenPixels = (redChannel == 0) & (greenChannel == maxValue) & (blueChannel == 0);
pureBluePixels = (redChannel == 0) & (greenChannel == 0) & (blueChannel == maxValue);
Use the one for red pixels and then call imshow() to see them. If you don't see anything then use
pureRedPixels = (redChannel <= 0.8*maxValue) & (greenChannel == 0) & (blueChannel == 0);
Keep lowering the 0.8 until you start to see something. I'm not sure exactly what color your red is. The initial code assumes red is (255,0,0) or (65535,0,0).

Più risposte (0)

Categorie

Scopri di più su Image Processing and Computer Vision 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!

Translated by