Page 4 of 8

Posted: Sat Jun 08, 2013 5:13 pm
by r57shell
Ti_ wrote:windows version? I've found only plugin exist.
It was about windows version of scolorq original program.
Ti_ wrote:you set 9 bit color, and after tries to change color quanity - and bits changed too!
Don't panic, just forget about bits.

Posted: Sat Jun 08, 2013 5:15 pm
by Ti_
Sega16: I've donwloaded last version of retrographics and tested again.

1)bug with not all tiles loaded fixed! (hah it's first win version that can open tiles).

2) I've also retested 4 rows palette generic algorithm: actually it generate little artifacts, but kept more colors.
From 64 colors palette: (4 raw) 51 unique colors!
From other image I got only 37 colors, but from 3 rows.
Nice work!

Suggestions:
1) made an option, when palettes are generated, every first colors in each palette is black.
2) save as png, and after palette is generated - make message with unique colors count.

Posted: Sat Jun 08, 2013 5:43 pm
by Ti_
r57shell wrote:
Ti_ wrote:windows version? I've found only plugin exist.
It was about windows version of scolorq original program.
Oooh, I've found it.
More , if download source for windows, you will see:

Code: Select all

printf("Usage: spatial_color_quant <source image.rgb> <width> <height> <desired palette size> <output image.rgb> [dithering level] [filter size (1/3/5)]\n");
in this text [dithering level] , but in exe - no. ; wtf? :o

tried to use it... 10 minutes passed... still converting?
scolorq qcCi1U8.png 400 256 31 out.png 3

Posted: Sat Jun 08, 2013 5:58 pm
by r57shell
Ti_ wrote:in this text [dithering level] , but in exe - no. ; wtf? :o
Argh! I have downloaded Version 0.2. But, anyway Version 0.4 does not supports dither parameter :S.
Ti_ wrote:tried to use it... 10 minutes passed... still converting?
It supports only RAW images, and yes... it's realy slow.

Posted: Sat Jun 08, 2013 7:24 pm
by r57shell
Ok, here I made png support of scolorq
http://elektropage.ru/r57shell/scolorq.zip
Image
I will investigate algo to see ability for making genesis palette.

Posted: Sat Jun 08, 2013 7:49 pm
by Ti_
r57shell wrote:Ok, here I made png support of scolorq
http://elektropage.ru/r57shell/scolorq.zip
Image
I will investigate algo to see ability for making genesis palette.
Great!
I've tried also you picture - but without dither:

Code: Select all

scolorq_png.exe qcCi1U8.png 31 out.png 0.2 3
(other palette, I just use img to sega after)
Image
some details lost, but I like it more. Because it more close to pixel-art (chars icons), but background very bad without dither.

If you scale dithered image - you see lots of dots. (in emulator you use at least 2x scale), thats ugly.
But on hardware it must be good.[/img]

Posted: Sat Jun 08, 2013 8:00 pm
by Ti_
here:

2 pics combo: (not accurate, many colors lost because different pals in your and my pic)

Image

smoke looks much better!

Posted: Sun Jun 09, 2013 1:27 am
by r57shell
Woops! What is there?
Program. Fresh, right from compiler.
Sweet! Even sources included. :]
http://elektropage.ru/r57shell/scolorq_gen.zip

Posted: Sun Jun 09, 2013 8:11 am
by Ti_
r57shell wrote:Woops! What is there?
Program. Fresh, right from compiler.
Sweet! Even sources included. :]
http://elektropage.ru/r57shell/scolorq_gen.zip
Interesting.
I like mode 2 with dither 0.1

Mode 1 produce lower count than you specify. (so you must use greater count)

For your pic I made 2 version :

Code: Select all

scolor_gen qcCi1U8.png 36 outm1.png 0.1 3 1

Code: Select all

scolor_gen qcCi1U8.png 31 outm2.png 0.1 3 2
mode 2 looks better.

Posted: Sun Jun 09, 2013 11:29 am
by r57shell
Ti_ wrote:Mode 1 produce lower count than you specify. (so you must use greater count)
In usage noted: ignore duplicates. It means, they will remain. This mode for selection colors count more than need, and check that in result you have colors as needed.
It is some hack, so it's not supposed that result will be good.
Algorithm itself does not supposed to used with so low definition of colors. 24 bpp expected, or even more.

Posted: Mon Jun 10, 2013 12:39 am
by frederic
Finally I made a Perl script that uses ImageMagick and that generates something that the MD can actually display.

The script is here: http://edis.zapto.org/md/bitmap2md.pl
It needs two Perl modules : Image::Magick and Algorithm::Cluster. It should run on Windows.

Example usage:

Code: Select all

./bitmap2md.pl --resize 320x224 --colors 48 --sample forestmd.png --dither --output code.asm forest.png
--resize WxH (optional) resizes the input image (in memory, the file is not modified) before processing.
--colors N (optional) sets the number of colors in the output image (defaults to 60, must be between 1 and 60)
--sample file.png (optional) writes a sample of the image that is identical to what the MD will display (same number of pixels/colors and same color distribution, but unfortunately with a different palette).
--dither (optional) will make the script use dithering
--output file.asm will write some asm code into file.asm (tiles and palettes)

The format of the asm file should be self-explanatory. The code uses GNU as syntax but it is easy to convert to another syntax. Colors commented with "unused" in the code (if any) are not used in the tiles and can be changed. The script is quite slow (on a middle-end laptop, 10 seconds without dithering and 2 minutes with dithering for 320x224 pixels image).

A few sample images (left picture: original image, right picture: picture displayed by the Dgen emulator). Click to get a larger version.

Image

All pictures displayed by Dgen contains ~60 colors, except the cat (8 colors), the horse (8 colors), and the sunset (30 colors). They use dithering except the sunset, the cat, and the two drawings.

Here are the roms I used to make those screenshots:
http://edis.zapto.org/md/portrait.bin
http://edis.zapto.org/md/sunset.bin
http://edis.zapto.org/md/forest.bin
http://edis.zapto.org/md/squirrel.bin
http://edis.zapto.org/md/cat.bin
http://edis.zapto.org/md/rain.bin
http://edis.zapto.org/md/horse.bin

I'm not sure if the results are good or bad. I tried to use Retro Graphics Toolkit to compare but I can't get it to work (either it has some bugs or I'm bad, I'll try again soon).

Posted: Mon Jun 10, 2013 12:41 am
by frederic
Ti_ wrote:yes, it's inaccurate. wrong color interval (white color 224/224/224 instead of 255/255/255)
Thanks. Then I have to modify my script.

Posted: Mon Jun 10, 2013 1:12 am
by sega16
frederic wrote: I tried to use Retro Graphics Toolkit to compare but I can't get it to work (either it has some bugs or I'm bad, I'll try again soon).
Could you please explain why you can't get it to work so that I can fix it for you? Also here is a table based on real hardware that would be better for your script.

Code: Select all

0,49,87,119,146,174,206,255
Here is what I get out of retro Graphics Toolkit
Image
Your script outperformed retro graphics toolkit with the squirrel and I have not had time to test the other images.

Posted: Mon Jun 10, 2013 2:25 am
by frederic
sega16 wrote:Could you please explain why you can't get it to work so that I can fix it for you?
Sure. I just downloaded the last version just to be sure (https://github.com/ComputerNerd/Retro-G ... master.zip).

I run it, then I chose File > Import image to tilemap. Then I chose Palette Actions > generate optimal palette. I enter 60 colors and chose "Generate contiguous palette...". Only one palette is filled, but when I click somewhere in the palettes (palette editor tab), the rest fills itself. Here is what I get with the forest image:

Image

If I save it with "save tilemap to image", I get the same picture in the png file.
sega16 wrote: Also here is a table based on real hardware that would be better for your script.

Code: Select all

0,49,87,119,146,174,206,255
Thanks a lot! I updated my script. I'll test later to see the difference.

Thanks also for your test. I never used any tools like this so I was not sure if my results were good or not.

Posted: Mon Jun 10, 2013 3:21 am
by sega16
Goto tilemap actions->Dither tilemap as image
Then pick how you want the tilemap dithered.