I've been using Inkscape from many years converting pixel images to vectors using the Trace Bitmap tool, then edit and work on vectors to finally generate a png output, most of the times I use monochrome images and I convert using 8 or 16 scans.
Because Trace bitmap tool generate grayscale image with solid gray colors I use to select each one of the colors and manually convert to black and set the transparency according a scale implemented in the moment, so, the pure black stay on black with 0 transparency, then some #101010 gray go to black with #10 of transparency, some #202020 go to black with #20 of transparency and so on...
Now I need to work with a very complex image with many gray levels, so I need to make a 127 or more scans until I have a decent image based on vectors but I don't want to change manually every one of the 127 gray levels to a transparent color.
Is there any way to make the Trace bitmap tool to generate a black color with a transparency for each of the gray level?
Is there any filter that I can apply to the vector image to convert all the gray colors to black with transparency?
I've tried with Filter editor, Color Matrix, Luminance to Alpha but I'm a little older to understand the complexity of the filter editor, also I try almost all the filters and extensions and found nothing that made what I need.
I know that after export the image I can use Gimp to move grays to transparent, but I prefer to do all the things inside Inkscape because from time to time I need to retouch some vector and make the procedure again and I can forget the external step on Gimp (Still a little older and forgot too many things).
@inklinea How's it going? It would be useful if the z stack registers were individually selectable for edits like these. Do the whole z at the same time or break for isolated work. Modes, blends, blurs, etc. This is why we need the z.
@inklinea yes, Scan to black and replace gray color with a transparency level (Actually I do manually with 8 or 16 levels). Or if there any filter/extension that do something like this somebody give a clue what is it or how to use (I mean parameters), for example the color matrix, maybe the color matrix can replace gray colors with transparency levels.
The original registration extension I made, puts all scans into their own layer the order, of which corresponds with the original z-order of the scans.
As long as you don't drag or move things out of the layers that should remain forever. Selecting all in layer or clicking the group in that layer should allow for selection.
blluis - I know nothing about the filter editor - I think it's possible to do almost anything using its advance features - someone else on here may be better placed to comment.
However, the trace bitmap with greyscale option selected, does trace to traditional grey values as far as I can tell.
So equal values to r, g, b for each level of grey it produces. rgb(124, 124, 124) or hex #7F7F7F for example. Since these go from 0-255, It might be possible to convert that range into an opacity value. There might already be an option in the Bitmap trace or filters to do this which I don't know about !
I just wrote an extension that works, but only changes the colors to black, I can't figure out how to change the alpha or opacity, I suppose that converting rgba to rgb loose the alpha value, and if I return the rbga color, the object color set to unassigned, maybe somebody can help me with this, I found no extensions that deal with alpha or opacity values together with color values, I leave this example here but let me know if I should post to some other thread.
After doing a bitmap scan to greys and ungroupoing - the above should convert - to bw with opacity value
The reason for the mean ( average ) calculation, is sometimes greyscale image which do not come from bitmap scan can have slight variations across the channels such as 'slate grey' which contains blue.
The max / min values shown in the code are not used, but I suppose could be used for a bit of tweaking via an options box.
I think perhaps an offset slider might be useful too.
For my personal use it's ok and the code change the colors like a was doing manually, many, many traced bitmaps manually changed to alpha, in this case it's a good tool because I have to work with 128 gray levels.
Here is an example of a quick test that I do with a traced bitmap, as you can see in the second image, my goal is to change the background color and this color should be the final color of the image, indeed I need to use the image over a changing background color and it can't have white or gray colors, all colors should be transparent.
This is not what you asked for, but it might be what you need. I think it produces the same visual outcome; a colour bitmap converted to grey with alpha matched to the lightness. Skip the bitmap tracing and apply [Filters > Color > Greyscale...] then select the [Transparent] check box.
@inklinea We are talking the same language and seem to understand one another. Also, is your extension finalized? Would you post another image of it in the other thread?
I've been using Inkscape from many years converting pixel images to vectors using the Trace Bitmap tool, then edit and work on vectors to finally generate a png output, most of the times I use monochrome images and I convert using 8 or 16 scans.
Because Trace bitmap tool generate grayscale image with solid gray colors I use to select each one of the colors and manually convert to black and set the transparency according a scale implemented in the moment, so, the pure black stay on black with 0 transparency, then some #101010 gray go to black with #10 of transparency, some #202020 go to black with #20 of transparency and so on...
Now I need to work with a very complex image with many gray levels, so I need to make a 127 or more scans until I have a decent image based on vectors but I don't want to change manually every one of the 127 gray levels to a transparent color.
Is there any way to make the Trace bitmap tool to generate a black color with a transparency for each of the gray level?
Is there any filter that I can apply to the vector image to convert all the gray colors to black with transparency?
I've tried with Filter editor, Color Matrix, Luminance to Alpha but I'm a little older to understand the complexity of the filter editor, also I try almost all the filters and extensions and found nothing that made what I need.
I know that after export the image I can use Gimp to move grays to transparent, but I prefer to do all the things inside Inkscape because from time to time I need to retouch some vector and make the procedure again and I can forget the external step on Gimp (Still a little older and forgot too many things).
Thanks.
Do you mean that you want each scan to be black, but with an opacity percentage which tries to approximate the original grey colour which they had ?
@inklinea How's it going? It would be useful if the z stack registers were individually selectable for edits like these. Do the whole z at the same time or break for isolated work. Modes, blends, blurs, etc. This is why we need the z.
@inklinea yes, Scan to black and replace gray color with a transparency level (Actually I do manually with 8 or 16 levels). Or if there any filter/extension that do something like this somebody give a clue what is it or how to use (I mean parameters), for example the color matrix, maybe the color matrix can replace gray colors with transparency levels.
@inklinea I found something that I try before as I say on my first comment:
https://alpha.inkscape.org/vectors/www.inkscapeforum.com/viewtopic3945.html?t=11500
But the image goes to almost white.
Nelchai - it depends what you mean by z-order.
The original registration extension I made, puts all scans into their own layer the order, of which corresponds with the original z-order of the scans.
As long as you don't drag or move things out of the layers that should remain forever. Selecting all in layer or clicking the group in that layer should allow for selection.
blluis - I know nothing about the filter editor - I think it's possible to do almost anything using its advance features - someone else on here may be better placed to comment.
However, the trace bitmap with greyscale option selected, does trace to traditional grey values as far as I can tell.
So equal values to r, g, b for each level of grey it produces. rgb(124, 124, 124) or hex #7F7F7F for example. Since these go from 0-255, It might be possible to convert that range into an opacity value. There might already be an option in the Bitmap trace or filters to do this which I don't know about !
I just wrote an extension that works, but only changes the colors to black, I can't figure out how to change the alpha or opacity, I suppose that converting rgba to rgb loose the alpha value, and if I return the rbga color, the object color set to unassigned, maybe somebody can help me with this, I found no extensions that deal with alpha or opacity values together with color values, I leave this example here but let me know if I should post to some other thread.
file: color_graytoblackalpha.inx
file: color_graytoblackalpha.py
After doing a bitmap scan to greys and ungroupoing - the above should convert - to bw with opacity value
The reason for the mean ( average ) calculation, is sometimes greyscale image which do not come from bitmap scan can have slight variations across the channels such as 'slate grey' which contains blue.
The max / min values shown in the code are not used, but I suppose could be used for a bit of tweaking via an options box.
I think perhaps an offset slider might be useful too.
For my personal use it's ok and the code change the colors like a was doing manually, many, many traced bitmaps manually changed to alpha, in this case it's a good tool because I have to work with 128 gray levels.
Here is an example of a quick test that I do with a traced bitmap, as you can see in the second image, my goal is to change the background color and this color should be the final color of the image, indeed I need to use the image over a changing background color and it can't have white or gray colors, all colors should be transparent.
Image After Trace
Image after Gray to Blacked Alpha
So, thank you for your code. It will help me a lot.
This is not what you asked for, but it might be what you need. I think it produces the same visual outcome; a colour bitmap converted to grey with alpha matched to the lightness. Skip the bitmap tracing and apply [Filters > Color > Greyscale...] then select the [Transparent] check box.
@inklinea We are talking the same language and seem to understand one another. Also, is your extension finalized? Would you post another image of it in the other thread?
I've uploaded a rough version of this effect for Inkscape 1.1+ to https://gitlab.com/inklinea/grey-to-mono-alpha
It allows for any single colour to be used, and a lower and upper threshold to be applied to make sure nothing is completely solid.
Nelchai, the simple registration was completed a while ago, but I only write for Inkscape 1.1+ https://inkscape.org/~inklinea/%E2%98%85simple-registration
@inklinea Would it be best to upload a daily version of 1.1, or should users wait for a more secure release?
@NELCHAI, Please do not post off-topic messages in a conversation you did not originate. Continue on a new topic or one that relates directly.