Blurring/Filling in color on jpeg image.

조회 수: 1 (최근 30일)
Matthew Alston
Matthew Alston 2014년 6월 30일
편집: Matthew Alston 2014년 7월 11일
Hi,
I'm working with painmaps (see example attached), and I'm trying to shade in the red areas. As you can see the red is scribbled on and there are white spaces within, I'd like to take the outer extremities of the red scribbling and fill in everything inside of it red, so that it's one solid block of red. This is so that I can quantify the shaded pixels for analytical purposes. Any help with this would be much appreciated. I was thinking that perhaps imfill or morphological closing could be used, but I'm struggling to make either option work.
Thanks, Matt

채택된 답변

Image Analyst
Image Analyst 2014년 6월 30일
편집: Image Analyst 2014년 6월 30일
You need to do some steps like I showed you before to get the red scribbles. Then you need to call activecontour() to get the "envelope" of the red scribbles. See attached demo.
  댓글 수: 5
Image Analyst
Image Analyst 2014년 7월 10일
This code doesn't have the code I just gave you, so no wonder it doesn't fill in anything.
To go up between the legs you'd need a body template to multiply the thing by. You can try to align the template to your image, perhaps with imregister though I'm not sure ho well it would work on just a partial body.
Matthew Alston
Matthew Alston 2014년 7월 11일
편집: Matthew Alston 2014년 7월 11일
Yes sorry I forgot to explain that I was struggling to get the above code to work. Before I can extract the color channels I need to convert the image to rgb from grayscale right?
I used: rgbImage = cat(3, grayImage, grayImage, grayImage);
Then I extracted each color channel: % Extract the individual red, green, and blue color channels. redChannel = rgbImage(:, :, 1);
greenChannel = rgbImage(:, :, 2);
blueChannel = rgbImage(:, :, 3);
But when I get to this part I get stuck : "% Set image to pure red where binaryImage is true." This is the error message I get:
redChannel (binaryImage) = 255; Undefined function or variable 'binaryImage'.
Could you offer advice to what I'm doing wrong? Sorry I'm a very inexperienced Matlab user. The full code is attached to make it easier to view.

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

추가 답변 (0개)

Community Treasure Hunt

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

Start Hunting!

Translated by