1

I am trying to remove the pectoral muscle from a mammogram image. I did this by converting it to binary doing the the following:

img2=img<150;
imclearborder(img2); %since the pectoral muscle is usually at the border of the image 

This removes the pectoral muscle from the image. But I now need to convert the resulting image without the pectoral muscle back to grayscale. Can anyone advise me on how to do this please?

original image

Img with pectoral muscle img with pectoral muscle removed

The first image shows a binary version of the mammogram with the pectoral muscle in the top left hand corner. The second image shows the binary image with the pectoral muscle removed. I need to convert this image back to grayscale.

I have tried multiplying the original image with the resulting binary image but I get this :

multiplied image

asked May 22, 2014 at 13:24
3
  • 2
    How about multiplying your original image with the mask you just created: img.*img2? Commented May 22, 2014 at 13:28
  • I have tried this but it simply just turns the remaining object in the image gray. I have updated the question to show this. Commented May 22, 2014 at 13:43
  • 1
    Try Result = Remove - mask; So your muscle is now negative value, so threshold Result[Result > -1] = 1; and Result[Result < 0] = 0; So you have a new mask you can use on your original image. Commented May 22, 2014 at 13:45

1 Answer 1

1

Try

img2 = img < 150;
img3 = imclearborder(img2);
Result = img3 - img2; 

So your muscle is now negative value, you just have to threshold again

Result(Result > -1) = 1; 
Result(Result < 0) = 0; 

Or just by doing, it will be enough, because difference will be -1 and similar will be 0.

Result = Result + 1;

And you have a new mask. Finally, you can use it on your original image.

Final = uint8(Result).*img; 
answered May 22, 2014 at 13:46
Sign up to request clarification or add additional context in comments.

13 Comments

Thanks for this! I have tried the first line of code which produces the image of just the pectoral muscle. However when I try the following two lines I get a parse error at "=";
Sorry, I do so much python, I'm use to use bracket [], use () instead.
Thank you! Whenever I threshold again using this, nothing changes. The image with just the pectoral muscle remains the same.
You did something wrong. Because with the difference you are suppose to see what change between your original mask and the one pass into imclearborder. So With the difference, you extract your muscle, once it done just need to do the inverse of the muscle so your original image is change. I'll edit my post to fit with your variable name.
I have done this exactly but I get an error when trying to multiply checkForSameSizeAndClass(X, Y, mfilename);
|

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.