[need help] Tracing raster-to-vector process

Why not just put a white layer the size of the canvas behind the image?

Yes, I mentioned that at one point.

I think the key is to understand what the intended purpose is for vectorization. At the moment, it appears that Stefan wants to duplicate his raster images to such accuracy that I wonder why not just use the original raster.

@D_Gowers when you apply a stack scan, do you not get this?

Left being the traced vector stack, and right being the original raster image.

As for Inkscape version, I had 0.91 …I upgraded just now to 9.2 but still same effect.

@afre the reason I want a vector is because I enjoy the look and feel of them. But no offense …if you look at the colours I got, and how yellow the trace ended up compared to the rich reds and greens in the raster, I really don’t think I am demanding the moon and the stars here :stuck_out_tongue: I don’t see why it didn’t reproduce them properly in this mode when without stack scans it does …with annoying transparent spots.

Because the transparent spots do not show up where where is missing and it looks awkward and a bit overly light. A black layer does a better job yet darker than should. I’ll do a tutorial on the method I found solves it.

No offense taken. I was just wondering if vectorization is the best solution. An open question: maybe it is or maybe it isn’t. I mean you could get a similar look by manipulating a raster, unless you are willing to go deeper than simple tracing.

As for color shift, I do see the problem and empathize. However, I am not good with colors. I can see the difference between colors but somehow have trouble identifying them, so I have refrained from commenting on the subject.

If the color shift is regional, you could attempt to place shapes on top of the trace to blend and reach your target color. I have done this in the past when in a bind. There are many online tools that can help find the hexes you need.

Well here’s the “tutorial.” Looks like this is about as good as can be done in the current situation. Hope it’s helpful to anyone. I’d like to help you all for helping and joining the group effort :slight_smile:

Click Here for better quality version.

1 Like

… Well, the colors aren’t the exact same as in the raster version, if that’s what you mean (though I wouldn’t say they are quite as different as your picture shows… only a little dimmer than the original, which is a typical side effect of quantization).

However, the colors in a trace with the Stack option on are completely identical to the ones in a trace with the Stack option off – ie. the Stack Scans option does not affect colors at all. I can post a comparison if you want.

Checking up on this reminded me that the Preview pane in the Trace dialog should show exactly what colors you are gonna get, since it displays a thumbnail of the ‘preprocessed’ image (in this case, the image after it has been quantized to N colors). It’s interesting to note that in all frames of your tutorial the thumbnail shown has the reddish tone.

FWIW I’m running inkscape bzr r15625 (ie. trunk, which will eventually become release 0.93)

EDIT: I think I was tracing a different image than you meant though, I’ll retry.

Second try (originally I traced the OP image with your logo etc, now traced the correct tree image):

I see the traced result is displayed yellowish.
This is the actual bug.
The traced result is not yellow when exported!

Traced result as shown in gimp, inkscape, and sxiv

I’m not sure exactly what the cause of this bug is, but it seems pretty clear to me now it is an issue with Inkscape’s display.

1 Like

@D_Gowers so when you trace it with stack option on in inkscape, the result shows yellow like mine …but after you save the vector and open it in gimp it renders correctly? interesting. I haven’t tried saving it and rendering it, I assumed inkscape would display it right. I will try this at home tonight.

What I’m wondering now is …if one were to exit inkscape then restart it and open the saved vector, would it still show yellow or render right? If you can check before I get home please let me know, otherwise I’ll post results tonight. My version at first was 0.91 but last night I updated to 0.92, no difference in rendering though.

I took another look at the problem at different angles. My computer is incredibly under-powered – likely more so than yours, so there was a lot of waiting for the CPU/GPU to catch up and screen to refresh.

I tried saving the SVG and opening it again. I get

I also tried exporting the bitmap and traced object, respectively, using “Export PNG Image”. Takeaways:

  • On my system, exporting doesn’t remove the color shift. Since I don’t trust my eyes, I used a global system color picker to verify. Note the overlaid purple rectangle: I measured the top-left and bottom-right patches inside, comparing raster and vector in app and their exported versions.

  • The color shift isn’t uniform, which makes me suspect that it has to do with issues related to not only posterization but color conversion and management.

  • As @D_Gowers mentioned, Inkscape’s trace tool is based on Potrace. Have you tried using the tool directly? As-is, I don’t believe that Potrace is meant to trace color images.

I forgot to mention how I would deal with the transparency problem. Below is a quick and dirty method. There is some smoothing/dilation, but in my opinion it is an acceptable trade-off for increased color accuracy.

  • Select trace
  • Object > Ungroup
  • Path > Outset
  • You may tweak this by using. Preferences > Behavior > Steps

Outset paths by 1px:

PS To make the features less rounded, maybe outset a bit larger than 1px, then inset back to 1px. Again, my computer is super old, so I will let you try it.

1 Like

thanks for this! good technique to know!

No, I exported a PNG directly from Inkscape, The GIMP and sxiv screenshots were mainly to ascertain that color management wasn’t causing the variation in color.
I’ll re-trace and check the saving thing.

EDIT:
Results are as follows:

  • Saving the svg and re-loading into Inkscape makes no difference (still shown yellow)
  • Importing SVG into GIMP gives a similar result as exporting from Inkscape (ie. correct colors)
  • Importing the exported PNG back into Inkscape shows correct colors.

Like afre, I suspect that this may be related to color management.
Going on that theory, I also took the time to strip the PNG you provided (optipng -strip all 1ebc2a5b146dd249142dd686577b65581b9b7afd.png). This should remove any color management information (eg. gamma, ICC profile) that could have been influencing things.
Then I imported into Inkscape and traced this file.
Result: Still yellow!

Conclusion: Color management data on input image is not the cause. Bug is triggered by some particular aspect of the pixel data itself. Bug does not affect quantization (otherwise, export would use wrong colors).

Theory: Correct colors are assigned to vectors, then the wrong color management info is assigned to them. Export ignores this CM info (not implemented yet?) and so renders correctly.

However, examining the SVG generated by Inkscape does not reveal any color management information. So I’m still relatively clueless, but at least there is enough evidence in this thread to file a bug report.

@afre: If by ‘uniform’ you mean ‘doesn’t occur on all pictures’, I agree.
Last I checked PoTrace didn’t have any multitrace support; anyone who wants to implement it needs to at minimum generate an indexed image, sort its palette by perceptual brightness, and pretend that index == grey value as they repeatedly feed the same image into potrace, varying the --threshold value.

1 Like

@D_Gowers

I haven’t tried the first point but for me the PNG still exhibited incorrect colors.

Color Issues
I rarely use or follow the development of Inkscape anymore, but my impression is that it is fairly color management agnostic. There are a few controls in the GUI but they don’t do anything yet, unless I missed a new development. Stripping the metadata only worsens the situation if proper management exists, unless the metadata is incorrect in the first place. Moreover, PNG color profiling is still uncommon.

I wasn’t referring to the assigning or recognition of metadata but how Inkscape manipulates and handles (“manages”) the actual data. Anyway, color is a difficult nut to crack. @Elle’s website may help clarify some issues at play, though she focuses on raster processing.

Lastly, feel free to file a bug report, but I feel that we don’t have enough info to warrant proper attention. I suggest you bring this up in places where Inkscape developers are carrying out active conversation. As I don’t see an Inkscape Category on this forum, this might not be the best place to get results :wink:

1 Like

@D_Gowers I will try the exporting myself tonight. Didn’t get around to it yesterday unfortunately. Thanks a lot for the effort!

Well, that is exactly the case I was thinking of. But stripping the metadata also should guarantee an image is imported as plain sRGB, which (eg. in GIMP) often may work out to no transformation at all.

I’m basically just doing the standard debugging thing – eliminate possibilities.

I put your case down to version differences. Since I don’t completely understand the bug yet, I’m just working on what I can.

… That’s not different in a practical sense. If you aren’t using available CMS metadata to manage the image, then there is no guarantee that your pixelwise operations on the image will make any sense.

In any case, my tests were designed to eliminate the possibility that Inkscape was correctly color-managing the image based on wrongly set colorspace information, which AFAICS they did. It’s pretty likely IMO that color management is unrelated to this bug (but at the same time, it’s the only guess I have at what could cause it.)

In other words, I am fairly confident that my theory is wrong. But it’s still the only theory I have so far :slight_smile:

Hope you catch that bug :spider_web:

@D_Gowers i just tested it myself. the Stacks tracing produces the ugly yellow look in Inkscape but once saved it opens well in Gimp. Don’t get it :frowning:

Well, that makes two of us :slight_smile:
I’ve added a comment to this existing bug report that hopefully may prompt some feedback on how to properly track down the cause of this bug.

The only idea I have for that currently is to find another image that causes similar discoloration.

Maybe try it on these.

1 Like