achieve this effect
achieve this effect
Hi,
I have a sample image and I know it is achieved using ImageMagick. Can someone help achieving the same effect.
my image:
desired effect:
I tried to use morphology with close disk and also median parameters but the output was not like this.
Please help
Thank You
I have a sample image and I know it is achieved using ImageMagick. Can someone help achieving the same effect.
my image:
desired effect:
I tried to use morphology with close disk and also median parameters but the output was not like this.
Please help
Thank You
Re: achieve this effect
somebody please help
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: achieve this effect
I have tried but with little affect. Perhaps Anthony will have some better ideas using -morphology, this evening when he gets online. Perhaps he can come up with some kind of custom shape kernel that will simply erode corners into round shapes.
My best effort was:
convert otgd1y.png -blur 5x65000 -threshold 50% result.gif
But it is not converting square edges fully to round ones.
Edit:
Trying again, this seems to be better -- a large disk open morphology.
convert otgd1y.png -morphology open disk:8 result.gif
Anthony can probably fine tune the disk radius. The disk radius probably needs to be some fraction of the thickness of the black lines. A radius of 8-10 works with 8 being 1/3 the black line thickness of 24. A radius of 12 which is 1/2 of the thickness of 24 does not work well as it broadens too much together. A thickness of 6 which is about 1/4 of the black line thickness does not seem to work well either as it is not quite rounded enough.
OOPS: I reversed the rounding. Need to use close rather than open.
convert otgd1y.png -morphology close disk:8 result2.gif
It is not clear how you generated the original blocky image. If you used IM, you could draw rounded rectangles. See -draw at http://www.imagemagick.org/Usage/draw/#primitives
My best effort was:
convert otgd1y.png -blur 5x65000 -threshold 50% result.gif
But it is not converting square edges fully to round ones.
Edit:
Trying again, this seems to be better -- a large disk open morphology.
convert otgd1y.png -morphology open disk:8 result.gif
Anthony can probably fine tune the disk radius. The disk radius probably needs to be some fraction of the thickness of the black lines. A radius of 8-10 works with 8 being 1/3 the black line thickness of 24. A radius of 12 which is 1/2 of the thickness of 24 does not work well as it broadens too much together. A thickness of 6 which is about 1/4 of the black line thickness does not seem to work well either as it is not quite rounded enough.
OOPS: I reversed the rounding. Need to use close rather than open.
convert otgd1y.png -morphology close disk:8 result2.gif
It is not clear how you generated the original blocky image. If you used IM, you could draw rounded rectangles. See -draw at http://www.imagemagick.org/Usage/draw/#primitives
Re: achieve this effect
There were a couple of posts about this last year but I have no idea what to search for to find them.
Re: achieve this effect
I need to replicate exact effect. if you see closely the curve and some of the corners are very different, which are not being generated by morphology with close disk, smooth disk, applying median.
I am 100% sure this effect is achieved by imagemagick as there were some other affects too, which I exactly replicated using imagemagick but this one is a tough one.
I will really appreciate if someone could help me in this matter. I have spent about 2 days but could not achieve this effect.
Thank You
I am 100% sure this effect is achieved by imagemagick as there were some other affects too, which I exactly replicated using imagemagick but this one is a tough one.
I will really appreciate if someone could help me in this matter. I have spent about 2 days but could not achieve this effect.
Thank You
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: achieve this effect
I don't know how to do any better than what I explained above. I doubt there is any one unique function in IM that will do that. Perhaps Anthony will have some ideas. My other suggestion is to draw it from scratch using -draw and round rectangles or circles where needed.
Where did you get the idea that IM could do that exactly as desired?
Where did you get the idea that IM could do that exactly as desired?
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: achieve this effect
Note Open and Close will do two aspects of the puzzel. You probably want to do both. 'Smooth' which does a 'Open followed by a Close'
But make sure your disk radius is slightly smaller than 1/2 the line distance or you could wipe out single pixels.
however the diagonal joins make the results a little lop-sided.
As such I think you may be better of either using using dilate or erode using diamond, then reverse the process using disk.
Try this...
Another alternative is to blur the image using Gaussian, then threshold at 50%, which produces a very weird effect!
So you only then need to figure out what you want done for 'diagonal joins'.
But make sure your disk radius is slightly smaller than 1/2 the line distance or you could wipe out single pixels.
however the diagonal joins make the results a little lop-sided.
As such I think you may be better of either using using dilate or erode using diamond, then reverse the process using disk.
Try this...
Code: Select all
convert code.png -morphology Dilate Diamond:11 -morphology Erode Disk:11.3 code_1.png
Another alternative is to blur the image using Gaussian, then threshold at 50%, which produces a very weird effect!
Code: Select all
convert code.png -blur 0x5 -threshold 50% code_2.png
So you only then need to figure out what you want done for 'diagonal joins'.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: achieve this effect
Note that your image
is actually inconsistent!
Any white squares surrounded by 3 blacks in a corner are in one case left sharp, and in another being rounded.
Also white squares are being treated as differently to black squares!
Finally the results show two different radii of circular archs. A half line thickness, and a full line thickness! That will not be so easily to reproduce!
I think this may be a case of specific 'patterns' of 'pixels' being tiled with a specific shaped tile image. And that is a much more involved process, which may be harder to implement generally. It would be possible, but you need to figure out exactly what 3x3 pattern produces what tile. That is 2^9 or 512 patterns, though that may be quartered with rotations, and halved with mirrors down to 2^6 or 64 unique patterns!
If a diamond neighbour hood is used that reduces to 16 unique patterns. But that does not appear to be the case. For example see the white square surrounded by black on all but one corner!
One pattern missing in the example image is a diagonal line of white squares surrounded by black.
ASIDE: this is actually closely related to other examples I have dealt with. My Kernel2Image script
http://www.imagemagick.org/Usage/scripts/kernel2image
And examples in
http://www.imagemagick.org/Usage/morpho ... rnel2image
Also related to a current 'project' of mine, the expansion of bitmaps of 3-D 'voxels' shapes, into diagrams for building (in the sandbox building game "minecraft")
is actually inconsistent!
Any white squares surrounded by 3 blacks in a corner are in one case left sharp, and in another being rounded.
Also white squares are being treated as differently to black squares!
Finally the results show two different radii of circular archs. A half line thickness, and a full line thickness! That will not be so easily to reproduce!
I think this may be a case of specific 'patterns' of 'pixels' being tiled with a specific shaped tile image. And that is a much more involved process, which may be harder to implement generally. It would be possible, but you need to figure out exactly what 3x3 pattern produces what tile. That is 2^9 or 512 patterns, though that may be quartered with rotations, and halved with mirrors down to 2^6 or 64 unique patterns!
If a diamond neighbour hood is used that reduces to 16 unique patterns. But that does not appear to be the case. For example see the white square surrounded by black on all but one corner!
One pattern missing in the example image is a diagonal line of white squares surrounded by black.
ASIDE: this is actually closely related to other examples I have dealt with. My Kernel2Image script
http://www.imagemagick.org/Usage/scripts/kernel2image
And examples in
http://www.imagemagick.org/Usage/morpho ... rnel2image
Also related to a current 'project' of mine, the expansion of bitmaps of 3-D 'voxels' shapes, into diagrams for building (in the sandbox building game "minecraft")
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/
Re: achieve this effect
Thank you guys,
Now I believe its not possible with IM. Anyhow, can you please also tell me how do I smooth the edges of the curves? I am using autotrace but its not producing the correct result. I am using autotrace separately, as I didn't enable it while installing IM.
Now I believe its not possible with IM. Anyhow, can you please also tell me how do I smooth the edges of the curves? I am using autotrace but its not producing the correct result. I am using autotrace separately, as I didn't enable it while installing IM.
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: achieve this effect
Using a very small blur to smooth edges is onw way.
Autotrace is better, but may need special options to ensure it correctly determines 'corners'.
The original program that generated the example result, as I think I mentioned probably 'tiled' prepared images for each of the input 'pixel sized' squares. IM can do this but it really needs a highly specialized neighbourhood selection process to generate the array of tiles (which would be pre-drawn and already smoothed). At least for the example result you gave.
Autotrace is better, but may need special options to ensure it correctly determines 'corners'.
The original program that generated the example result, as I think I mentioned probably 'tiled' prepared images for each of the input 'pixel sized' squares. IM can do this but it really needs a highly specialized neighbourhood selection process to generate the array of tiles (which would be pre-drawn and already smoothed). At least for the example result you gave.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/
Re: achieve this effect
Thank You guys,
I used blur with 0.7 value and it worked well.
I used blur with 0.7 value and it worked well.