Jump to content

10

Quantizator


869 replies to this topic

#26 emkay OFFLINE  

emkay

    Quadrunner

  • 7,042 posts
  • What's up?
  • Location:Holy Grail ;)

Posted Mon Jan 18, 2010 1:43 AM

Simple batch file to make things easier.

This helps also if you forgot to name the source pic.

File: GO.BAT

If "%1" == "" goto error
Quantizator /i=%1 /o=%2
goto end


:error

rem no source file

:end



Matrix as simple:

go source.pic  output.pic

Setting the switches of Quantizator via editing the batch file to your wishes, save it and keep it easier to handle.

Edited by emkay, Mon Jan 18, 2010 1:49 AM.


#27 Philsan ONLINE  

Philsan

    River Patroller

  • 2,583 posts
  • New Orleans Saints Super Bowl XLIV Champions
  • Location:Switzerland

Posted Mon Jan 18, 2010 3:00 AM

Dune, one of my preferred games...

#28 AtariNerd OFFLINE  

AtariNerd

    Dragonstomper

  • 687 posts
  • On the planet that is farthest from.
  • Location:California

Posted Mon Jan 18, 2010 4:36 AM

Great tool as a first pass to get the most common color pallets per line to play with, with of course dithering to be tweaked and the image to be edited by hand for finer detail.

Be nice if you could open these in G2F. ;)

#29 PeteD OFFLINE  

PeteD

    Stargunner

  • 1,747 posts
  • Location:Wales

Posted Mon Jan 18, 2010 5:24 AM

View PostAtariNerd, on Mon Jan 18, 2010 4:36 AM, said:

Great tool as a first pass to get the most common color pallets per line to play with, with of course dithering to be tweaked and the image to be edited by hand for finer detail.

Be nice if you could open these in G2F. ;)

Doesn't it still output .mic and .col files? If so you can load those into G2F.


Pete

#30 José Pereira OFFLINE  

José Pereira

    River Patroller

  • 2,938 posts
  • Location:Lisbon - Portugal

Posted Mon Jan 18, 2010 8:26 AM

Hello.

As you all know I'm not a programmer but even not being one I would like to say something, just some theory but could help in your coding.


PROCESS IN THE WAY I SEE IT CAN BE DONE:
1.)- Convert Images into 160wide (2:1) Resol.
2.)- Convert "Point1" Image into 128 A8 colours.
3.)- Get the majour Darkness Colour in all High Screen Lines.
4.)- Get in each Lines the 2majour colours (PF0&1).
5.)- Divide in each Line into 4,4,4,... pixels (2:1 ratio). Now get the 2majour colours that aren't on the same tiles (PF2&3).
6.)- Get another 2majour collors with a predefined maxim area (that can be done Raster). Change Mid-Line of PF0 &/or PF1.
(Welcome back EMKAY!)


You'll have now 7colours.
About PMs. it could nor be difficult, and try first PRIOR4.
O.K. 7colours. untill now(Backgr.,4PFs,2s)Raters. Now find 4more majour colours that from 1st pixel untill last one doesn't exceed 32pixels one Area+8pixels another Area or 40pixels. from 1st to last pixel. And also (the most important) doesn't have Backgr. colour pixels in this Area. Fill this colours 4Areas with Backgr. colour and now simple in PRIOR4 you can add the 4Players or the 4Players+4Missiles. According to size of the Area you'll get the PMs. in Normal,Double or Quadruple Lenght.


11Colours, not bad. very well indeed.
A.)- Save this into an A8 format or into .g2f (or .ged if it it is with RASTERS) that people can change the way they wants/think it's better.
B.)- Save the Unusued colours, so that people can freely/manually enhanced picture.
C.)- You can also Dither the Areas of the unusued colours in a pseudo Image. Good to do Manually changes.


Probably nothing new in my words. But probabbly and in some way a Method in various stages of getting into a good final result.

I also think that, because of PRIOR0 get different possible combinations you do not have to go into this, but PRIOR0, like I said/show isn't so difficult. Am I right?
Ando with the Dither in Unusued colour Areas, people can also change mannually things in G2F. Using PRIOR0 can be a matter of taste of eachone.
I still think that we have to do something. Not all done. What's the good in that?
Why I have pleasure in spend my time in my pictures re-making? Yes, even me can't show/explain why!... But I have!


Greetings.
José Pereira.

#31 emkay OFFLINE  

emkay

    Quadrunner

  • 7,042 posts
  • What's up?
  • Location:Holy Grail ;)

Posted Mon Jan 18, 2010 11:39 AM

The idea of using straight colour registers is the best resulting to get with such tool.
Ofcourse someone could somwhere in time create a perfect converter using all possible hw features.
But, hey, having the PM for later additional stuff isn't bad.
Having more acurrate colours after importing, result in even better images.

The problem is that the image is "round" after importing all possible details with 4 colours per scanline. Changing colours after importing, destroys the main picture.
Midline changes for having more colour per scanline available, helps to keep more details of the original picture. No need for charmode there. Not using PMg helps adding them for stuff like mouse pointer, additional text or some additional work on the imported picture.


@Philsan
Particular Dune is a candidate for playing with the palette. 256 colours at it's best. 16 Bit Pokey sounds makes some AdLib concurring music possible.

For details we could use those "imported" pictures. For movie scenes some interlace mode works well.
Flying with the Ornithopter yells for some gr. 10 animated screen. Nightfights do well with gr. 9 set to green ...
Maps could be build with hires and PM colouring....and so on.
Everything is there.

Edited by emkay, Mon Jan 18, 2010 11:47 AM.


#32 ilmenit OFFLINE  

ilmenit

    Moonsweeper

  • 275 posts

Posted Mon Jan 18, 2010 12:28 PM

Hi,

Thanks a lot for your feedback. In a few days I'll be back from a business trip and I get back to work on this tool.
Meanwhile Mono has ported the sources to linux.
http://atarionline.p...ttachmentID=408

The Quantizator still has a few bugs that I know about (preview pictures are not exactly the same as the output, there is a bug in /col parameter etc.)
I will fix it in a newer version. The color changes in line and sprites will be added sooner or later, but I have two other Atari projects with a bit higher priority. They are almost done (a few nights to finish), while developing and testing the Quantizator with sprites and color changes will take probably more.

best regards :)

#33 PeteD OFFLINE  

PeteD

    Stargunner

  • 1,747 posts
  • Location:Wales

Posted Mon Jan 18, 2010 1:27 PM

I'm actually working on something similar although it's at a very early stage atm compared to quantizator.   As the app I'm writing already has colour reduction/remapping etc in I'd thought about doing a scanline one then saw quantizator and decided not to bother, then I got bored a couple of days ago and added it anyway :)

It's really simple atm, just 4 most popular colours, no dithering, no perceptual colour checks, no options, no PMG or mid scanline although I'm looking at adding it all in the near future so maybe the A8 community will have 2 similar tools for graphics conversion, or maybe one if one of us gets it working really well (like ilmenit I've got other code I should be writing) :)

Here's an example of a C64 conversion...

Original
exile_01.gif

4colours per line
exile remapped laoo newbmp.png

That image works pretty well because there aren't really many more than 4 colours per line in most of it ;)  I'll upload some more complex images when I've worked on the code a little more.  And this for example is what mine does to that dune image..

dune remapped.png

You can see there's less "lining" than quantizator but also less colour difference (the insect is just totally remapped to the more popular purple).

*edit*
Forgot to mention there's no checking for 2:1 AR pixels atm, this is just a 4 colour/line routine so that Dune image is in 320 not 160 although that makes no difference to the remapping, just the res.


Pete

Edited by PeteD, Mon Jan 18, 2010 1:52 PM.


#34 ivop OFFLINE  

ivop

    Chopper Commander

  • 208 posts
  • Location:The Netherlands

Posted Mon Jan 18, 2010 6:07 PM

I couldn't resist. Here's a quick hack:

#! /bin/sh

numcols=4

case $1 in
	*.gif) c=giftopnm ;; *.jpg) c=jpegtopnm ;; *.png) c=pngtopnm ;;
	*) echo 'ugh' >&2 ; exit 1 ;;
esac

$c $1 | pnmscale -xsize 160 -ysize 240 > tmp1.ppm

for i in `seq 0 239`; do
	j=`printf "foo%03d.ppm" $i`
	k=`printf "bar%03d.ppm" $i`
	pnmcut -left 0 -top $i -height 1 -width 160 tmp1.ppm > $j
	pnmquant -fs $numcols $j > $k
done

pnmcat -topbottom bar*.ppm | pnmscale -xsize 320 -ysize 240 -nomix > $1.ppm

rm -f tmp1.ppm foo*.ppm bar*.ppm

Input files should be 320:240 aspect ratio, output is 320x240, but pixels are 2:1 and four colours per line.

Examples:

alone.gif.ppm.png dune.png.ppm.png exile_01.gif.ppm.png
Last_ninja_cover.png.ppm.png transarctica_02.png.ppm.png

#35 PeteD OFFLINE  

PeteD

    Stargunner

  • 1,747 posts
  • Location:Wales

Posted Mon Jan 18, 2010 6:22 PM

hehe, not bad, now make it work with PMGs and mid scanline changes ;)  If it wasn't for those possibilities there'd be no point writing new code :)


Pete

#36 ivop OFFLINE  

ivop

    Chopper Commander

  • 208 posts
  • Location:The Netherlands

Posted Mon Jan 18, 2010 6:48 PM

View PostPeteD, on Mon Jan 18, 2010 6:22 PM, said:

hehe, not bad, now make it work with PMGs and mid scanline changes ;)  If it wasn't for those possibilities there'd be no point writing new code :)

True, though I did not invest that much time in it :)

Just experimenting with other pnmquant options and using -spreadluminosity instead of the default -spreadbrightness, and alternating gave me this:

(brightness, luminosity, both alternating)

Last_ninja_cover.png.ppm.png Last_ninja_cover.png.lumi.ppm.png Last_ninja_cover.png.alt.ppm.png

transarctica_02.png.ppm.png transarctica_02.png.lumi.ppm.png transarctica_02.png.alt.ppm.png

et cetera...

I like it how the image gets more nuances if you combine both quantisation steps.

Perhaps I'll look into mid-scanline changes tomorrow. I'm fairly sure that can be done with netpbm/pbmplus commandline tools too ;)

Code changes for those who want to run it themselves, change the pnmquant line to:

	test `echo $(( $i % 2 ))` -eq 0 && s=-spreadluminosity || s=
	pnmquant $s -fs $numcols $j > $k


#37 emkay OFFLINE  

emkay

    Quadrunner

  • 7,042 posts
  • What's up?
  • Location:Holy Grail ;)

Posted Tue Jan 19, 2010 1:35 AM

Quantization via midline changes really should be the next goal.




#38 ilmenit OFFLINE  

ilmenit

    Moonsweeper

  • 275 posts

Posted Tue Jan 19, 2010 1:37 AM

View Postivop, on Mon Jan 18, 2010 6:48 PM, said:

Perhaps I'll look into mid-scanline changes tomorrow. I'm fairly sure that can be done with netpbm/pbmplus commandline tools too ;)

I'm very curious about the result. If you want to make it right, you have to change just a one color at time, keeping the rest untouched.
As I see with netpbm you don't quantize the lines into a choosen Atari palette (128 colors). Try it, if this tool allows, because the quality of some pictures decrease a lot, when you do that as a post processing step.

#39 PeteD OFFLINE  

PeteD

    Stargunner

  • 1,747 posts
  • Location:Wales

Posted Tue Jan 19, 2010 2:58 AM

I hand't checked to see if those were remapped to 128 A8 palette (although they kind of look like they are) and of course the quality can change a lot when that happens, especially depending on which hue is most popular.

Doing mid-scanline with existing remappers is probably possible by running the remapper to 4 colours over 2 sections then making 2 palettes with the top 3 in each and a unique colour for each but I can add that to my code really easily now all the other functions are there. Adding PMG support is more non-generic because of the pixel size differences etc.

It's nice to be able to use existing stuff if it's capable of the job, I just wonder why nobody has these ideas 10 years ago, it might have kicked off a remapper frenzy :)

*edit*
The quantize step does look pretty good on some of those, especially the ninja ones (until you remap them to a8 then they drop in quality a bit) and from a bit of googling I see it's median cut.  I might add that to mine to see what it does.  I put in the two standard diversity algorithms last night and as is usual with those, sometimes it's really good and other times it's a bit crap ;)  4 colours really isn't a lot for the modified diversity to do much different than the original diversity algorithm :(


Pete

Edited by PeteD, Tue Jan 19, 2010 3:23 AM.


#40 ivop OFFLINE  

ivop

    Chopper Commander

  • 208 posts
  • Location:The Netherlands

Posted Tue Jan 19, 2010 7:00 AM

View Postilmenit, on Tue Jan 19, 2010 1:37 AM, said:

View Postivop, on Mon Jan 18, 2010 6:48 PM, said:

Perhaps I'll look into mid-scanline changes tomorrow. I'm fairly sure that can be done with netpbm/pbmplus commandline tools too ;)

I'm very curious about the result. If you want to make it right, you have to change just a one color at time, keeping the rest untouched.
As I see with netpbm you don't quantize the lines into a choosen Atari palette (128 colors). Try it, if this tool allows, because the quality of some pictures decrease a lot, when you do that as a post processing step.

No midline changes yet, but I did experiment some more with other pnmquant options (-center, -meancolor and -meanpixel).

Left column is the same as as the post above (-center is default), middle column is -meancolor and the right column is -meanpixel:

nine.png

I think I like the bottom right the best. As for remapping to the Atari palette, I noticed it really matters which palette you use.

Saturation 80:

sat80.png
nine-remap-80.png

Saturation 60:

sat60.png
nine-remap-60.png

Also, consider that the quality of the source material matters a lot too. Here's the bottom right method on a slightly adjusted source image (gimp: brightness -16, contrast +32) and remapped to the Atari palette:

br-16_con+32.png

Notice how the letters are much more defined and there's a shade of blue in the ninja's hood.

#41 PeteD OFFLINE  

PeteD

    Stargunner

  • 1,747 posts
  • Location:Wales

Posted Tue Jan 19, 2010 7:15 AM

Definitely the source image being messed with a bit can produce much better results although that's kind of because you've just filtered out some of the shades from the image and highlighted others.  That probably won't work as well on a more colourful/bright picture.  I'm going to add some pre-conversion sliders to mine so you can change HLS a bit, remap, change, remap etc if you want as it does make a difference apart from possibly losing some shades, it helps to highlight some colours that might otherwise be ignored.

The problem with any of these quantizing methods is sometimes one produces better lines then the other one does.  It's going to need either some matching algorithm and a multipass run or some user choice maybe picking sections from different conversions.

*edit*
Just for the sake of being pedantic ;) Which palette is used to remap that last image?  and is it 128 or 256 colours?  The tiny palette images you posted are 256 and even that 1/2 shades can make a lot of difference.


Pete

Edited by PeteD, Tue Jan 19, 2010 7:18 AM.


#42 ilmenit OFFLINE  

ilmenit

    Moonsweeper

  • 275 posts

Posted Tue Jan 19, 2010 8:04 AM

View PostPeteD, on Tue Jan 19, 2010 7:15 AM, said:

Just for the sake of being pedantic ;) Which palette is used to remap that last image?  and is it 128 or 256 colours?  The tiny palette images you posted are 256 and even that 1/2 shades can make a lot of difference.

True. Remember, that in gr. mode 15 only 128 color palette is available.

#43 ivop OFFLINE  

ivop

    Chopper Commander

  • 208 posts
  • Location:The Netherlands

Posted Tue Jan 19, 2010 8:11 AM

View Postilmenit, on Tue Jan 19, 2010 8:04 AM, said:

View PostPeteD, on Tue Jan 19, 2010 7:15 AM, said:

Just for the sake of being pedantic ;) Which palette is used to remap that last image?  and is it 128 or 256 colours?  The tiny palette images you posted are 256 and even that 1/2 shades can make a lot of difference.

True. Remember, that in gr. mode 15 only 128 color palette is available.

Yeah, I forgot :roll:

Here's the last image again. The first one is remapped straight to the 128 colours palette, the second one is first remapped to the 256 palette and then to 128.

last.straight128.ppm.png last.via256to128.ppm.png
sat60-128.png

#44 irwin OFFLINE  

irwin

    Space Invader

  • 34 posts

Posted Tue Jan 19, 2010 8:25 AM

Guys - ivop, ilmenit, PeteD - very good work, but maybe its time for add some Zuul's, Gozer's or even scariest ghosts, and sprites like pmg0 or pmg3.

;)

#45 PeteD OFFLINE  

PeteD

    Stargunner

  • 1,747 posts
  • Location:Wales

Posted Tue Jan 19, 2010 9:26 AM

View Postivop, on Tue Jan 19, 2010 8:11 AM, said:


Yeah, I forgot :roll:


I'm not being arsey with you it's just when two of us have written code specifically to do this so that it's easier to add the mid scanline, pmg and any other stuff then you post images that aren't in A8 palette, then are but double the colours or have the source colours reduced by changing brightness it's hard to compare which code has the best quantization method.   So far the pnmquant LN looks the best but to be honest I prefer my Exile and Dune, but based on the pnmquant LN one I'm going to include median cut algorithm in my code as my LN still doesn't look as good even with the contrast/brightness adjustment.

There's no problem with there being 3 apps that do the same thing as long as it's all to the benefit of the end user.


Pete

Edited by PeteD, Tue Jan 19, 2010 9:52 AM.


#46 José Pereira OFFLINE  

José Pereira

    River Patroller

  • 2,938 posts
  • Location:Lisbon - Portugal

Posted Tue Jan 19, 2010 10:00 AM

Hello.

Someone around here can help me?
I'm trying to Load the "Quantizator" but I got ERROR.
Tried different versions from here and AtariOnline but all the same.


Help, please?
Thanks.
José Pereira.

#47 José Pereira OFFLINE  

José Pereira

    River Patroller

  • 2,938 posts
  • Location:Lisbon - Portugal

Posted Tue Jan 19, 2010 10:10 AM

View PostJosé Pereira, on Tue Jan 19, 2010 10:00 AM, said:

Hello.

Someone around here can help me?
I'm trying to Load the "Quantizator" but I got ERROR.
Tried different versions from here and AtariOnline but all the same.


Help, please?
Thanks.
José Pereira.


Join all files (including dll42 that says was missing). Get a little more this time. I've enter in Quantizator Program (Name on Top Blue Bar, all Screen Black) but says: "ERROR Quantizator.exe input file".

How you Load this great Utility?


Thanks.
José Pereira.

#48 PeteD OFFLINE  

PeteD

    Stargunner

  • 1,747 posts
  • Location:Wales

Posted Tue Jan 19, 2010 10:14 AM

View PostJosé Pereira, on Tue Jan 19, 2010 10:10 AM, said:

View PostJosé Pereira, on Tue Jan 19, 2010 10:00 AM, said:

Hello.

Someone around here can help me?
I'm trying to Load the "Quantizator" but I got ERROR.
Tried different versions from here and AtariOnline but all the same.


Help, please?
Thanks.
José Pereira.


Join all files (including dll42 that says was missing). Get a little more this time. I've enter in Quantizator Program (Name on Top Blue Bar, all Screen Black) but says: "ERROR Quantizator.exe input file".

How you Load this great Utility?


Thanks.
José Pereira.

Have you tried running it from the commandline like it tells you to?  with a filename and some options, like it tells you to? ;)  You can probably drag/drop an image onto the exe but then you can't give it any options.  Or make a bat file with %1 and the options already there and drag/drop onto that.


Pete

#49 José Pereira OFFLINE  

José Pereira

    River Patroller

  • 2,938 posts
  • Location:Lisbon - Portugal

Posted Tue Jan 19, 2010 10:37 AM

Attached File  Quantizator097.zip   1.27MB   89 downloads

PeteD:
This is one of the Quantizator versions.
I'm trying to understand but remember I'm not coder (%1, bat...) and English Language...
(I ut there an Arkanoid Image).

Try to run it and see for yourself what you get.

Thanks.
José Pereira.

#50 PeteD OFFLINE  

PeteD

    Stargunner

  • 1,747 posts
  • Location:Wales

Posted Tue Jan 19, 2010 10:42 AM

José, that works fine for me.   Simply drag/drop the bmp onto the quantizator.exe and if you still get an error then you must be missing some dll or something still.

%1 .bat, that's not really coding ;) it's standard dos/windows stuff.

make a new file (text file) in the same folder rename it to quant.bat, right click on it, chose the option to edit it and put a line in as follows..

quantizator.exe %1      then follow that with any options you want to add from the readme.txt  eg
quantizator.exe %1 /mode=local /dist=euclid

save the file then you can drag/drop bmp,gif,etc onto the icon for the quant.bat and it will run quantizator with those options.


Pete

Edited by PeteD, Tue Jan 19, 2010 10:56 AM.





0 user(s) are browsing this forum

0 members, 0 guests, 0 anonymous users