Page 1 of 1
Cutting out a part of an Image using Magick++
Posted: 2009-10-15T11:25:36-07:00
by billabonk
Hi guys. I'm pretty new to Magick++.
I have this Image:
http://img517.imageshack.us/img517/3784/yoyoyo.jpg
I want to create a mask out of the colorful part in the middle.
So basically what I need to do is:
Make the colorful thingy in the middle white and make the black and grey areas on the outside complete black.
But how? I have no idea. Please help me!
Re: Cutting out a part of an Image using Magick++
Posted: 2009-10-15T11:45:59-07:00
by fmw42
Unfortunately, your background black is not pure black. So my attempts to use -threshold failed to isolate the center region without "eating away" some of it. I tried to use the red channel and hue channel as well with no good results.
convert yoyoyo.jpg -channel red -separate +channel -threshold XX% yoyoyo_0_c2.gif
where you can vary XX% around 1-10%
see -threshold
http://www.imagemagick.org/script/comma ... #threshold
This also eats away at the center
convert yoyoyo.jpg -channel red -separate +channel +dither -colors 2 -threshold 10% yoyoyo_0_c2.gif
Perhaps others might have some better ideas.
The only thing to do is use some thing like GIMP or Photoshop to manually draw a mask around the center area and create a b/w binary mask
Re: Cutting out a part of an Image using Magick++
Posted: 2009-10-15T12:16:47-07:00
by billabonk
Alright. So the starting image wasn't good in the first place.
Well thing is I actually created it myself.
I had these 2 Images:
http://img260.imageshack.us/img260/9058/50033144.jpg
http://img378.imageshack.us/img378/8666/smalljg.jpg
As you can see the HQ Version has some kind of error in it. I want to create a mask of it using the small version.
I resized the small Image to the size of the HQ Version using Image.zoom() and then used Image.composite() with MinusCompositeOp. Is there a better way to create a mask? Im still enw to this stuff :/
Re: Cutting out a part of an Image using Magick++
Posted: 2009-10-15T13:38:35-07:00
by fmw42
the problem is your first (larger image) is not totally black inside the center area. to be honest, I am still not sure what you are trying to do. If you created the first image with the darker inside, then how did you get the smooth outline for the shape? Did you draw that in some GUI image processing tool such as GIMP or Photoshop? If so, then you should be able to create a binary mask at the same time in that tool. What is your final objective and what are the functional steps you think you need to get there?
You either need to find some segmentation or thresholding technique that will separate the shape from the background or trace it manually in some GUI application and fill the inside with white and the outside with black.