Export to bitmap without interpolation ?

Post unfinished work here for feedback and advise.
Ghislain_B
Posts: 2
Joined: Mon Nov 25, 2013 5:59 pm

Export to bitmap without interpolation ?

Postby Ghislain_B » Mon Nov 25, 2013 6:23 pm

Hi all,
I have a really small image (a few pixels) that I can't upload as a svg for some reason.
Let's say it's just a 10*10 pixels square with a gradient (0->255) on it, on a black background.
I would like to export it to a bit map without any interpolation (so that every pixel takes the exact value at its coordinates, even if we lose details in the process).
Is there a way to do this ?

I saw that it is possible to draw the file to a bigger size and then resize it with Gimp, but it seems overly complicated for the task and I need exact values at every pixel on my tiny image.

User avatar
Johannski
Posts: 65
Joined: Wed May 05, 2010 3:13 am
Location: Austria
Contact:

Re: Export to bitmap without interpolation ?

Postby Johannski » Wed Nov 27, 2013 10:48 pm

Hey There!

This is actually not the right subforum you're posting, but whatever.
I made a file, just as you described it, and also added a line, for showing that there is actually no interpolation, if it has the right size and position. Here's the svg: http://openclipart.org/detail/189168/small-pixel-test-by-johannski-189168

The result looks like this (After creating a 10x10 image with inkscape, I resized, so it is easier to see the pixels):
Image

As you can see, there is no interpolation between the blue line and the background. So I the vectors are, where the pixels will be, there will be no interpolation.
Image

tylerdurden
Posts: 2344
Joined: Sun Apr 14, 2013 12:04 pm
Location: Michigan, USA

Re: Export to bitmap without interpolation ?

Postby tylerdurden » Wed Nov 27, 2013 11:16 pm

You might check out pixel-accurate comments in this topic on the Pixelsnap extension:
viewtopic.php?f=14&t=3653
Have a nice day.

I'm using Inkscape 0.92.2 (5c3e80d, 2017-08-06), 64 bit win8.1

The Inkscape manual has lots of helpful info! http://tavmjong.free.fr/INKSCAPE/MANUAL/html/

Lazur
Posts: 4717
Joined: Tue Jun 14, 2016 10:38 am

Re: Export to bitmap without interpolation ?

Postby Lazur » Thu Nov 28, 2013 3:03 am

Or that recent topic that points to microUgly's fine method:
http://www.inkscapeforum.com/viewtopic.php?f=5&t=16509

Ghislain_B
Posts: 2
Joined: Mon Nov 25, 2013 5:59 pm

Re: Export to bitmap without interpolation ?

Postby Ghislain_B » Thu Nov 28, 2013 4:29 am

Thanks for your responses.
I learned a lot since my first message, so I'll be able to explain my "problem" more explicitly.
Johannski actually helped me figure out that what I miscalled "interpolation" is just a "mean of values inside the pixel". If I understood well, this is the value taken when you export to a bitmap. Which is a good choice most of the time.
But instinctively, I thought that the "value at the center of the pixel" would be taken instead.
Here is a concrete visual explanation.
SVG file : SVG Image
PNG after exporting : Image
PNG made 8x bigger in ImageJ (no interpolation) : Image

-The black rectangles are fine, because they are correctly aligned on the pixel grid.
-The gradients also, since the mean of values inside a pixel are equal to the value at its center (it's a linear gradient).
-But the square that is rotated by 45 degrees shows values that were not supposed to be here (I would like it to be 255 or 0, nothing else, even if it doesn't resemble a square anymore in the end).
-Another example that doesn't appear in the image above : if I moved a black rectangle by 0,25 pixels to the right, its borders would be "blurry", like for the rotated square.

Again, I think the way exporting currently works is perfect in most of the cases. I just have a particular need, and I'm getting used to do the little trick consisting in exporting at 9000pp (image is 100times bigger) and then downsizing the image in ImageJ without interpolation. It's not perfect, especially with gradients (depending on the direction of the gradient, -> or <-), but I didn't find anything better. Here is what I obtain with this method :
Image
Bigger : Image
Good enough for me !

In conclusion, you helped me understand better my problem, and my need is so specific that now I understand why it's not an option in Inskape.
I will do the 100x trick.
Thanks a lot !


Return to “Work in progress”