Converting image into graphics
Clash Royale CLAN TAG#URR8PPP
up vote
9
down vote
favorite
I have a black-white image, but it is rather blurry so I was thinking of converting it into vector graphics so I could do some coloring. This is the image:
img = Import["https://i.stack.imgur.com/cyHjC.jpg"];
I used Binarize
with ImageGraphics
, but the result is not so good:
img2 = Binarize[ImageApply[If[Mean@# < 0.9, #, 1, 1, 1] &, img], 0.8]
ImageGraphics[Erosion[img2, 1], 2, Method -> "LinearSeparable", 10]
As you can see, the lines are pretty rough with weird curves here and there.
ImageGraphics
tends to deal with much more complicated stuff, so I thought maybe it is possible to optimize this with the knowledge that this is a black and white image with only the lines required. But how?
graphics image-processing
add a comment |Â
up vote
9
down vote
favorite
I have a black-white image, but it is rather blurry so I was thinking of converting it into vector graphics so I could do some coloring. This is the image:
img = Import["https://i.stack.imgur.com/cyHjC.jpg"];
I used Binarize
with ImageGraphics
, but the result is not so good:
img2 = Binarize[ImageApply[If[Mean@# < 0.9, #, 1, 1, 1] &, img], 0.8]
ImageGraphics[Erosion[img2, 1], 2, Method -> "LinearSeparable", 10]
As you can see, the lines are pretty rough with weird curves here and there.
ImageGraphics
tends to deal with much more complicated stuff, so I thought maybe it is possible to optimize this with the knowledge that this is a black and white image with only the lines required. But how?
graphics image-processing
Could you post the image here directly?
â Carl Lange
4 hours ago
@CarlLange edited, thanks.
â t-smart
4 hours ago
It doesn't look very blurry to me. What kind of coloring is it that you want to do?
â C. E.
3 hours ago
1
Hm. I usually don't suggest to use external programs but I've just tried it with Inkscape (import the image, go to "Path" -> "Trace bitmap", and use "Brightness cutoff" 0.8). It was easy as cake.
â Henrik Schumacher
2 hours ago
What is this image? It's nice and I collect such graphics, so I am just curious.
â Vitaliy Kaurov
41 mins ago
add a comment |Â
up vote
9
down vote
favorite
up vote
9
down vote
favorite
I have a black-white image, but it is rather blurry so I was thinking of converting it into vector graphics so I could do some coloring. This is the image:
img = Import["https://i.stack.imgur.com/cyHjC.jpg"];
I used Binarize
with ImageGraphics
, but the result is not so good:
img2 = Binarize[ImageApply[If[Mean@# < 0.9, #, 1, 1, 1] &, img], 0.8]
ImageGraphics[Erosion[img2, 1], 2, Method -> "LinearSeparable", 10]
As you can see, the lines are pretty rough with weird curves here and there.
ImageGraphics
tends to deal with much more complicated stuff, so I thought maybe it is possible to optimize this with the knowledge that this is a black and white image with only the lines required. But how?
graphics image-processing
I have a black-white image, but it is rather blurry so I was thinking of converting it into vector graphics so I could do some coloring. This is the image:
img = Import["https://i.stack.imgur.com/cyHjC.jpg"];
I used Binarize
with ImageGraphics
, but the result is not so good:
img2 = Binarize[ImageApply[If[Mean@# < 0.9, #, 1, 1, 1] &, img], 0.8]
ImageGraphics[Erosion[img2, 1], 2, Method -> "LinearSeparable", 10]
As you can see, the lines are pretty rough with weird curves here and there.
ImageGraphics
tends to deal with much more complicated stuff, so I thought maybe it is possible to optimize this with the knowledge that this is a black and white image with only the lines required. But how?
graphics image-processing
graphics image-processing
edited 3 hours ago
C. E.
47.9k391193
47.9k391193
asked 6 hours ago
t-smart
783113
783113
Could you post the image here directly?
â Carl Lange
4 hours ago
@CarlLange edited, thanks.
â t-smart
4 hours ago
It doesn't look very blurry to me. What kind of coloring is it that you want to do?
â C. E.
3 hours ago
1
Hm. I usually don't suggest to use external programs but I've just tried it with Inkscape (import the image, go to "Path" -> "Trace bitmap", and use "Brightness cutoff" 0.8). It was easy as cake.
â Henrik Schumacher
2 hours ago
What is this image? It's nice and I collect such graphics, so I am just curious.
â Vitaliy Kaurov
41 mins ago
add a comment |Â
Could you post the image here directly?
â Carl Lange
4 hours ago
@CarlLange edited, thanks.
â t-smart
4 hours ago
It doesn't look very blurry to me. What kind of coloring is it that you want to do?
â C. E.
3 hours ago
1
Hm. I usually don't suggest to use external programs but I've just tried it with Inkscape (import the image, go to "Path" -> "Trace bitmap", and use "Brightness cutoff" 0.8). It was easy as cake.
â Henrik Schumacher
2 hours ago
What is this image? It's nice and I collect such graphics, so I am just curious.
â Vitaliy Kaurov
41 mins ago
Could you post the image here directly?
â Carl Lange
4 hours ago
Could you post the image here directly?
â Carl Lange
4 hours ago
@CarlLange edited, thanks.
â t-smart
4 hours ago
@CarlLange edited, thanks.
â t-smart
4 hours ago
It doesn't look very blurry to me. What kind of coloring is it that you want to do?
â C. E.
3 hours ago
It doesn't look very blurry to me. What kind of coloring is it that you want to do?
â C. E.
3 hours ago
1
1
Hm. I usually don't suggest to use external programs but I've just tried it with Inkscape (import the image, go to "Path" -> "Trace bitmap", and use "Brightness cutoff" 0.8). It was easy as cake.
â Henrik Schumacher
2 hours ago
Hm. I usually don't suggest to use external programs but I've just tried it with Inkscape (import the image, go to "Path" -> "Trace bitmap", and use "Brightness cutoff" 0.8). It was easy as cake.
â Henrik Schumacher
2 hours ago
What is this image? It's nice and I collect such graphics, so I am just curious.
â Vitaliy Kaurov
41 mins ago
What is this image? It's nice and I collect such graphics, so I am just curious.
â Vitaliy Kaurov
41 mins ago
add a comment |Â
1 Answer
1
active
oldest
votes
up vote
5
down vote
Your image is too small, so post-processing algorithms run into a lot of errors as initial information is tiny. Right form the start significantly resize image (upsample) trying to "guess" what info in the image is missing. As you are using original image
i = Import["https://i.stack.imgur.com/cyHjC.jpg"]
to do this before post-processing ImageResize
will do a great job as it will have all available info. The lesson here is: do not upsample after some post-processing stages as some info is getting lost during these operations. BTW ImageResize
generally upsamples nicely in my experience. Now both Binarize
and ImageGraphics
will have much more "room" to work and you get a very high quality vector:
ImageGraphics[Binarize[ImageResize[i, 2000], .8],2,Method -> "Exact"]
You can export it into a vector format
Export["vector.SVG", vector]
but because Stack Exchange cannot render .SVG (unfortunately) I uploaded it for you HERE and below is a raster copy. Now you can play further various improvement routs found in Image Restoration and other guides, but the key point is to increase image resolution from the start.
add a comment |Â
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
5
down vote
Your image is too small, so post-processing algorithms run into a lot of errors as initial information is tiny. Right form the start significantly resize image (upsample) trying to "guess" what info in the image is missing. As you are using original image
i = Import["https://i.stack.imgur.com/cyHjC.jpg"]
to do this before post-processing ImageResize
will do a great job as it will have all available info. The lesson here is: do not upsample after some post-processing stages as some info is getting lost during these operations. BTW ImageResize
generally upsamples nicely in my experience. Now both Binarize
and ImageGraphics
will have much more "room" to work and you get a very high quality vector:
ImageGraphics[Binarize[ImageResize[i, 2000], .8],2,Method -> "Exact"]
You can export it into a vector format
Export["vector.SVG", vector]
but because Stack Exchange cannot render .SVG (unfortunately) I uploaded it for you HERE and below is a raster copy. Now you can play further various improvement routs found in Image Restoration and other guides, but the key point is to increase image resolution from the start.
add a comment |Â
up vote
5
down vote
Your image is too small, so post-processing algorithms run into a lot of errors as initial information is tiny. Right form the start significantly resize image (upsample) trying to "guess" what info in the image is missing. As you are using original image
i = Import["https://i.stack.imgur.com/cyHjC.jpg"]
to do this before post-processing ImageResize
will do a great job as it will have all available info. The lesson here is: do not upsample after some post-processing stages as some info is getting lost during these operations. BTW ImageResize
generally upsamples nicely in my experience. Now both Binarize
and ImageGraphics
will have much more "room" to work and you get a very high quality vector:
ImageGraphics[Binarize[ImageResize[i, 2000], .8],2,Method -> "Exact"]
You can export it into a vector format
Export["vector.SVG", vector]
but because Stack Exchange cannot render .SVG (unfortunately) I uploaded it for you HERE and below is a raster copy. Now you can play further various improvement routs found in Image Restoration and other guides, but the key point is to increase image resolution from the start.
add a comment |Â
up vote
5
down vote
up vote
5
down vote
Your image is too small, so post-processing algorithms run into a lot of errors as initial information is tiny. Right form the start significantly resize image (upsample) trying to "guess" what info in the image is missing. As you are using original image
i = Import["https://i.stack.imgur.com/cyHjC.jpg"]
to do this before post-processing ImageResize
will do a great job as it will have all available info. The lesson here is: do not upsample after some post-processing stages as some info is getting lost during these operations. BTW ImageResize
generally upsamples nicely in my experience. Now both Binarize
and ImageGraphics
will have much more "room" to work and you get a very high quality vector:
ImageGraphics[Binarize[ImageResize[i, 2000], .8],2,Method -> "Exact"]
You can export it into a vector format
Export["vector.SVG", vector]
but because Stack Exchange cannot render .SVG (unfortunately) I uploaded it for you HERE and below is a raster copy. Now you can play further various improvement routs found in Image Restoration and other guides, but the key point is to increase image resolution from the start.
Your image is too small, so post-processing algorithms run into a lot of errors as initial information is tiny. Right form the start significantly resize image (upsample) trying to "guess" what info in the image is missing. As you are using original image
i = Import["https://i.stack.imgur.com/cyHjC.jpg"]
to do this before post-processing ImageResize
will do a great job as it will have all available info. The lesson here is: do not upsample after some post-processing stages as some info is getting lost during these operations. BTW ImageResize
generally upsamples nicely in my experience. Now both Binarize
and ImageGraphics
will have much more "room" to work and you get a very high quality vector:
ImageGraphics[Binarize[ImageResize[i, 2000], .8],2,Method -> "Exact"]
You can export it into a vector format
Export["vector.SVG", vector]
but because Stack Exchange cannot render .SVG (unfortunately) I uploaded it for you HERE and below is a raster copy. Now you can play further various improvement routs found in Image Restoration and other guides, but the key point is to increase image resolution from the start.
edited 41 mins ago
answered 1 hour ago
Vitaliy Kaurov
56k6156274
56k6156274
add a comment |Â
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmathematica.stackexchange.com%2fquestions%2f183174%2fconverting-image-into-graphics%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Could you post the image here directly?
â Carl Lange
4 hours ago
@CarlLange edited, thanks.
â t-smart
4 hours ago
It doesn't look very blurry to me. What kind of coloring is it that you want to do?
â C. E.
3 hours ago
1
Hm. I usually don't suggest to use external programs but I've just tried it with Inkscape (import the image, go to "Path" -> "Trace bitmap", and use "Brightness cutoff" 0.8). It was easy as cake.
â Henrik Schumacher
2 hours ago
What is this image? It's nice and I collect such graphics, so I am just curious.
â Vitaliy Kaurov
41 mins ago