Isolate structures from image

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
4
down vote

favorite












I have a medical brain image from which I'm trying to isolate the brain (the gray pixels) from the rest (black and white parts).



I'm looking for some functions that are best suited for this.



Thanks



enter image description here










share|improve this question





















  • Something like DeleteSmallComponents@Dilation[Binarize[img, 0.4, 0.6], 1] perhaps.
    – C. E.
    1 hour ago














up vote
4
down vote

favorite












I have a medical brain image from which I'm trying to isolate the brain (the gray pixels) from the rest (black and white parts).



I'm looking for some functions that are best suited for this.



Thanks



enter image description here










share|improve this question





















  • Something like DeleteSmallComponents@Dilation[Binarize[img, 0.4, 0.6], 1] perhaps.
    – C. E.
    1 hour ago












up vote
4
down vote

favorite









up vote
4
down vote

favorite











I have a medical brain image from which I'm trying to isolate the brain (the gray pixels) from the rest (black and white parts).



I'm looking for some functions that are best suited for this.



Thanks



enter image description here










share|improve this question













I have a medical brain image from which I'm trying to isolate the brain (the gray pixels) from the rest (black and white parts).



I'm looking for some functions that are best suited for this.



Thanks



enter image description here







image-processing






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked 1 hour ago









holistic

1,143620




1,143620











  • Something like DeleteSmallComponents@Dilation[Binarize[img, 0.4, 0.6], 1] perhaps.
    – C. E.
    1 hour ago
















  • Something like DeleteSmallComponents@Dilation[Binarize[img, 0.4, 0.6], 1] perhaps.
    – C. E.
    1 hour ago















Something like DeleteSmallComponents@Dilation[Binarize[img, 0.4, 0.6], 1] perhaps.
– C. E.
1 hour ago




Something like DeleteSmallComponents@Dilation[Binarize[img, 0.4, 0.6], 1] perhaps.
– C. E.
1 hour ago










1 Answer
1






active

oldest

votes

















up vote
4
down vote



accepted










This can actually be done quite gracefully. Since it seems like there's no full white within the brain itself, we replace all the White with Black, then use ImageCrop.



ImageCrop[DeleteSmallComponents@ColorReplace[i, White -> Black]]


You can use RemoveBackground as well if you don't want black in the background.



working example



older attempt



We use RemoveBackground with a marker in the centre of the image, then crop, delete small leftovers of the borders, crop again, and finally replace transparency with black.



RemoveAlphaChannel[
ImageCrop[
ColorNegate[
DeleteSmallComponents[
ColorNegate[
ImageCrop[
RemoveBackground[i, "Foreground", ImageDimensions[i]/2]]]]]],
RGBColor[0.`, 0.`, 0.`]]


working example



Or, since it seems like the image is relatively standard, you can just set given borders for the brain and crop to that every time.






share|improve this answer






















  • Thank you very much, that was easier than I thought :)
    – holistic
    1 hour ago










Your Answer




StackExchange.ifUsing("editor", function ()
return StackExchange.using("mathjaxEditing", function ()
StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix)
StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["$", "$"], ["\\(","\\)"]]);
);
);
, "mathjax-editing");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "387"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
convertImagesToLinks: false,
noModals: false,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













 

draft saved


draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmathematica.stackexchange.com%2fquestions%2f184234%2fisolate-structures-from-image%23new-answer', 'question_page');

);

Post as a guest






























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes








up vote
4
down vote



accepted










This can actually be done quite gracefully. Since it seems like there's no full white within the brain itself, we replace all the White with Black, then use ImageCrop.



ImageCrop[DeleteSmallComponents@ColorReplace[i, White -> Black]]


You can use RemoveBackground as well if you don't want black in the background.



working example



older attempt



We use RemoveBackground with a marker in the centre of the image, then crop, delete small leftovers of the borders, crop again, and finally replace transparency with black.



RemoveAlphaChannel[
ImageCrop[
ColorNegate[
DeleteSmallComponents[
ColorNegate[
ImageCrop[
RemoveBackground[i, "Foreground", ImageDimensions[i]/2]]]]]],
RGBColor[0.`, 0.`, 0.`]]


working example



Or, since it seems like the image is relatively standard, you can just set given borders for the brain and crop to that every time.






share|improve this answer






















  • Thank you very much, that was easier than I thought :)
    – holistic
    1 hour ago














up vote
4
down vote



accepted










This can actually be done quite gracefully. Since it seems like there's no full white within the brain itself, we replace all the White with Black, then use ImageCrop.



ImageCrop[DeleteSmallComponents@ColorReplace[i, White -> Black]]


You can use RemoveBackground as well if you don't want black in the background.



working example



older attempt



We use RemoveBackground with a marker in the centre of the image, then crop, delete small leftovers of the borders, crop again, and finally replace transparency with black.



RemoveAlphaChannel[
ImageCrop[
ColorNegate[
DeleteSmallComponents[
ColorNegate[
ImageCrop[
RemoveBackground[i, "Foreground", ImageDimensions[i]/2]]]]]],
RGBColor[0.`, 0.`, 0.`]]


working example



Or, since it seems like the image is relatively standard, you can just set given borders for the brain and crop to that every time.






share|improve this answer






















  • Thank you very much, that was easier than I thought :)
    – holistic
    1 hour ago












up vote
4
down vote



accepted







up vote
4
down vote



accepted






This can actually be done quite gracefully. Since it seems like there's no full white within the brain itself, we replace all the White with Black, then use ImageCrop.



ImageCrop[DeleteSmallComponents@ColorReplace[i, White -> Black]]


You can use RemoveBackground as well if you don't want black in the background.



working example



older attempt



We use RemoveBackground with a marker in the centre of the image, then crop, delete small leftovers of the borders, crop again, and finally replace transparency with black.



RemoveAlphaChannel[
ImageCrop[
ColorNegate[
DeleteSmallComponents[
ColorNegate[
ImageCrop[
RemoveBackground[i, "Foreground", ImageDimensions[i]/2]]]]]],
RGBColor[0.`, 0.`, 0.`]]


working example



Or, since it seems like the image is relatively standard, you can just set given borders for the brain and crop to that every time.






share|improve this answer














This can actually be done quite gracefully. Since it seems like there's no full white within the brain itself, we replace all the White with Black, then use ImageCrop.



ImageCrop[DeleteSmallComponents@ColorReplace[i, White -> Black]]


You can use RemoveBackground as well if you don't want black in the background.



working example



older attempt



We use RemoveBackground with a marker in the centre of the image, then crop, delete small leftovers of the borders, crop again, and finally replace transparency with black.



RemoveAlphaChannel[
ImageCrop[
ColorNegate[
DeleteSmallComponents[
ColorNegate[
ImageCrop[
RemoveBackground[i, "Foreground", ImageDimensions[i]/2]]]]]],
RGBColor[0.`, 0.`, 0.`]]


working example



Or, since it seems like the image is relatively standard, you can just set given borders for the brain and crop to that every time.







share|improve this answer














share|improve this answer



share|improve this answer








edited 1 hour ago

























answered 1 hour ago









Carl Lange

1,313318




1,313318











  • Thank you very much, that was easier than I thought :)
    – holistic
    1 hour ago
















  • Thank you very much, that was easier than I thought :)
    – holistic
    1 hour ago















Thank you very much, that was easier than I thought :)
– holistic
1 hour ago




Thank you very much, that was easier than I thought :)
– holistic
1 hour ago

















 

draft saved


draft discarded















































 


draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmathematica.stackexchange.com%2fquestions%2f184234%2fisolate-structures-from-image%23new-answer', 'question_page');

);

Post as a guest













































































Popular posts from this blog

How to check contact read email or not when send email to Individual?

Displaying single band from multi-band raster using QGIS

How many registers does an x86_64 CPU actually have?