ImageMagick

Can someone help me create a specific filtering process?
Im trying to convert image to 9-bit RGB and from 512 total available colors I want to force the image to use only 8 of them total for the final output.

Other urls found in this thread:

imagemagick.org/discourse-server/
imagemagick.org/Usage/quantize/tmaps_list.txt
twitter.com/NSFWRedditVideo

Just quit uni now, you don't cut it

I already finished mine,this is something i need to do on few images in my free time.

I don't know how to do what you want (did you try "-colors 8"?). When I have questions and Google search I'm almost always linked to the IM forums ('users' subforum):

imagemagick.org/discourse-server/

If you post there I would recommend providing an image example and show them the code you attempted to use.

Good luck.

>512 total available colors
as in a fixed palette?
>force the image to use only 8 of them total
8 bits of colour? or 8 colours?

From what ive gathered

>converts in.png -remap 512colors.png out.png
>convert out.png -posterize 2 out_2.png

First line will recolor the picture using 512 color palette.
Second line will limit 2 colors per channel giving me 8 colors on screen total.

Out of 512 colors possible,image will pick and use only 8 of them.

>convert*
obviously ignore the typo

What are you doing, making Genesis backgrounds? I'm not sure you can make IM choose a fixed palette out of a larger fixed palette. You may have to do it yourself.

Actually, why don't you ask Stack Overflow and post the link here? It's an interesting question I'll may research later when I have the time, but on Sup Forums your thread will probably just expire and that will be it.

generate a text file of 512 colours from the input
convert input.png -colors 512 -unique-colors palette.txt
take an input, remap it to use the 512 colours, then quantize it to 8 colours
convert input.png -dither FloydSteinberg -remap palette.txt -colors 8 output.png

pic related, 512 colour and 8 colour version

Other user corrected me I should have said that the pallet for the 512 colors is fixed.
As in the pic related.
I dont need palette created from the input image.

>What are you doing, making Genesis backgrounds?
PC-88 V2 mode

>I dont need palette created from the input image.
that's fine, my answer doesn't /have/ to use the input image as the palette source, i just used it because i needed something for a source

here i use your supplied palette;
convert 1487319030170.jpg -dither FloydSteinberg -remap pc88_512.png -colors 8 pc88.png

-- and since i know what video mode you're talking about, here's in 640x200 (scaled to 4:3) just because

actually correct ratio might be nice, too

There seems to be vastly different way to achieve a result,image that will be using only 8 colors.

>-colors
>The actual number of colors in the image may be less than your request, but never more. Note that this a color reduction option.

>-posterize
>reduce the image to a limited number of color levels per channel.


While we are at this do I have to call vertical dither from a xml file?
Cant I do it directly from console?

here's going directly from an arbitrary 4:3 image to the final PC-88 one
convert source.png -colorspace RGB -resize '640x200!' -colorspace sRGB -dither FloydSteinberg -remap pc88_512.png -colors 8 target.png

posterize shouldn't matter, as you're only picking colours from a know-valid palette anyway, so you can't end up with invalid colours

>While we are at this do I have to call >vertical dither from a xml file?
Cant I do it directly from console?
i don't know what you're talking about

to be clear, the example in is just the 640x200 output stretched to 640x480, which is something that will happen when you display your 640x200 image on a pc-88 when using a 4:3 monitor. this is simply an approximation of how it'll look on the pc-88's monitor

>posterize shouldn't matter
I agree but my point was something else.

In both ways I end up with the picture that has 8 colors.
-colors gives more colorful picture based on the amount of a specific tone (light/dark) of the picture.

-posterize argument on '2' means to only provide 2 colors per color channel, producing a map of just 8 colors for a 3 channel RGB image, such as the above. Basically it will recolor images using the threshold set of 8 colors.

>i don't know what you're talking about
imagemagick.org/Usage/quantize/tmaps_list.txt

you want ordered dither?
convert source.png -colorspace RGB -resize '640x200!' -colorspace sRGB -remap pc88_512.png -ordered-dither o2x2,3 -colors 8 -depth 8 -colorspace RGB -resize '640x480!' -colorspace sRGB test.png

There are multiple variations of ordered dither one of them being the one you used 'diffused pixel' and others like the one I was asking a vertical line one.
There is a sample of it included in the software and I was wondering if I can call it through the console or I need to call it from file.
Pic relater is the dither pattern.


Since you answered my question earlier,thank you.
We now now there are 2 ways of doing things and the rest I will figure out myself.
Thread can be closed.

didn't see a built in vertical dither map, so i wrote one
convert source.png -colorspace RGB -resize '640x200!' -colorspace sRGB -ordered-dither vlines,8 +dither -colors 8 -colorspace RGB -resize '640x480!' -colorspace sRGB test.png

~/.magick/thresholds.xml :


Simple Vertical Line Dither

1 2 3 4
1 2 3 4
1 2 3 4
1 2 3 4

hope this is closer to what you wanted

ps. i'm unsure how best to combine both this kind of dither along with picking 8 colours out of a predefined palette
i would personally go for an error-diffusion dither, but i guess you're trying to match an existing style, modding a pc-88 VN perhaps?

-- mapped colours and with no other dither
convert source.png -colorspace RGB -resize '640x200!' -colorspace sRGB +dither -remap pc88_512.png -ordered-dither vlines,3 -colors 8 -depth 8 -colorspace RGB -resize '640x480!' -colorspace sRGB test.png
there's probably a better way to do this, i'm not really that familiar with posterization

I was trying to use your vertical line filter but it seems that none of the dither effects work on a posterized image,the image just stays the same.
why I dont know but it does work if you apply it before posterization but with terrible results.

If i use -color the vertical lines dither effect works at both cases.
Strange.

The problem with this is a two-step conversion will yield greater error than one-step conversion.

remember that dither only makes a difference when you're reducing the number of colours (quantizing), that's the point of dither, to try to make a lower colour image look more like the higher colour version
the problem is that once you've applied one method, the second method can't do the best job it can, since it's now working with an already-quantized image

you can try to balance them, but you're really just hurting the quality of the image to get the effect of both types. maybe that's what you want?
convert source.png -colorspace RGB -resize '640x200!' -colorspace sRGB -dither floydsteinberg -remap pc88_512.png -ordered-dither vlines,8 -colors 8 -depth 8 -colorspace RGB -resize '640x480!' -colorspace sRGB test.png

i understand that, but op's working with a system with a fixed 512-colour palette, he has no choice but to pick 8 colours from that palette, rather than directly the best 8 colours for a given image

fug. i just noticed i had overwritten the pc88 palette file at some point and was making non-ideal images
convert source.png -colorspace RGB -resize '640x200!' -colorspace sRGB -dither floydsteinberg -remap pc88_512.png -ordered-dither vlines,3 -colors 8 -depth 8 -colorspace RGB -resize '640x480!' -colorspace sRGB test.png

I don't mean that. What I mean is that the error will be diffused differently, affecting the dithering and maybe even the color choice, if you convert from true color to 512 colors and then to 8 colors out of those 512 instead of picking the best 8 colors out of the 512 available directly because color information will be lost twice. However, I don't know any software that does the latter.

hmm, i see what you mean, i'll look into it

I dont have the floydsteinberg dither in my version hold on let me try to find it.
But the results seem promising with vlines,3.

>download GIMP
>perform color quantization
>select 8 for total number of colors
is this all your looking for OP?

doesn't take into account the fixed 512-colour palette
and afaik gimp can only use custom palettes up to 256-colour

Oh shit, ImageMagick! I remember using that! That was fucking years ago! Wow, are people still using that? Thanks for the nostalgia trip anyway, but I'm gonna stick with The GIMP.

It works fine but the lines are still packed too tight.
I cant tell on this picture if its just a checkerboard or vertical but that's the spacing I am aiming at.

that image is hand-drawn, the patterns were probably just part of the brushes used in the drawing program used to make the image

yes I know Im just trying to get the lines to look like as close to it.
I am ok with the current set up although the image is slightly darker than I would want.

probably the closest you could get in an automated fashion, would be to use an image that is fairly flat in the first place, such as anime/cartoon/clipart/vector/etc, do selective blur on it if it's lossy to avoid rough edges during posterization, then quantize that to 8 colours

bumping up the contrast can help it pick stronger colours

convert /tmp/a.png -colorspace RGB -resize '640x200!' -colorspace sRGB +dither -remap pc88_512.png -ordered-dither vlines,4 -colors 8 -filter point -resize '640x400!' test.png
i'll have to head off now

Bye user and thanks for the vlines.

np

-colors 8