Jump to content
IGNORED

Quantizator


ilmenit

Recommended Posts

Hi,

I'm experiencing this kind of issue: ...

 

The palette is wrong. I looks like red and green is switched (RGB <-> BGR)

This is caused by:

A) The picture being "different" from others (size, pixel-format or something)

B) the palette used for Atari is false, currupt or inaccessible

 

- If the same picture works on a different computer it then A) is not the case. I would try another palette as option. Maybe they aren´t accessible on the computer or corrupt. Look if they are available.

 

- If the same picture doesn´t work on any computer try converting to a different format (JPG->PNG / PNG->BMP / BMP->PNG / GIF->PNG) (but never to JPG or GIF or quality loss can happen). Or try to crop a pixel in width.

 

If it works I am interested in the cause. If not please attach the picture and the "test.bat" that starts rastaconverter.

Link to comment
Share on other sites

The palette is wrong. I looks like red and green is switched (RGB <-> BGR)

This is caused by:

 

A) The picture being "different" from others (size, pixel-format or something)

B) the palette used for Atari is false, currupt or inaccessible

 

none of the above

 

 

- If the same picture works on a different computer it then A) is not the case. I would try another

 

palette as option. Maybe they aren´t accessible on the computer or corrupt. Look if they are available.

 

palettes are ok, I've also tried default.act which has more bright colors, but it was also scrambled.

 

When I remove palettes, program gives an error, so its definately not a palette issue.

 

- If the same picture doesn´t work on any computer try converting to a different format (JPG->PNG / PNG->BMP / BMP->PNG / GIF->PNG) (but never to JPG or GIF or quality loss can happen). Or try to crop a pixel in width.

 

 

it works on any other than the one I can use as dedicated converter.

 

If it works I am interested in the cause. If not please attach the picture and the "test.bat" that starts rastaconverter.

 

 

test bat: start RastaConverter.exe manga_chick.png /dither=chess

post-14124-0-93255300-1335785295.png

 

Regards,

Martin

Link to comment
Share on other sites

Well I figured it out.

 

It happens when system runs at 16bit color depth instead of 32bit... remote desktop tries to save bandwith so it switches to 16bit and cause this palette crap.

 

Anyway, this issue is not only linked to RDP, so when I switched color depth locally on my computer (which I use to write this post), I get same scrambled palettes.

 

Dunno how to fix this... but at least i know what causes it.

 

Regards,

Martin

Link to comment
Share on other sites

It happens when system runs at 16bit color depth instead of 32bit... remote desktop tries to save bandwith so it switches to 16bit and cause this palette crap.

Maybe the result is OK anyway and only the desktop is screwed. Have you tested the result?

Dunno how to fix this... but at least i know what causes it.

Maybe there is a simple solution and the source can be patched. But I think it is OK if it only runs in True Color Mode.

Edited by 1NG
Link to comment
Share on other sites

Dunno how to fix this... but at least i know what causes it.

 

Do you checked the output file? Chances are high that only the display is wrong.

 

yes, I checked output file... it's all wrong.

As I wrote before, u can try it yourself, just change screen color depth to highcolor and u'll see...

Link to comment
Share on other sites

emkay, come back when you've reached 100,000,000 permutations ... ;) The first 70% goes relatively quickly, while probability plays its hand as time progresses and as more of the image is optimized, the longer it takes to see progress. . Some areas will still seem relatively untouched, while some are polished. I'm not sure what the Atari's limits are or how this software goes about determining them, so one may be waiting in vain..Maybe, if there were some sort of little indicator to pop up stating that we are getting pretty close to the theoretical limit...say within 5% or less of Atari resources... Heck, maybe it does already and I've just never have gotten that far? :D It might be we just have to get used to some imperfection and be willing to go in by hand and retouch through some sort of editor.

 

(Sometimes, autocorrect is a real pain.)

 

To wait for "max. iterations" may not be as fun as one might think. The converter uses up to 8 colours per scanline. But it could use more colours when more changes on a scanline appear. .... you know... more than 20 colours were possible.

 

post-2756-0-03397500-1335808902_thumb.jpg

 

Here a 127 colour dither picture...

 

post-2756-0-90717000-1335808922_thumb.png

 

There are simply more details.

Link to comment
Share on other sites

Hi Jakub,

 

I've checked source of rastaconverter, and it can be improved to boost calculations...

 

for instance function

double RGByuvDistance(rgb &col1, rgb &col2)

and

inline void RGBtoYUV(double r, double g, double b, double &y, double &u, double &v)

uses doubles to calculate conversion from RGB->YUV and calculates distance...

 

It could be replaced with 8-bit calculation like this:

Y = ( (  66 * R + 129 * G +  25 * B + 128) >>  +  16
U = ( ( -38 * R -  74 * G + 112 * B + 128) >>  + 128
V = ( ( 112 * R -  94 * G -  18 * B + 128) >>  + 128

Intermediate values are 16bit, but R,G,B,Y,U,V are 8bit usigned chars.

 

Also distance could be integer-like variable then.

I'm curious whats the difference between calculating distance in RGB and YUV color space... is that RGB2YUV conversion really needed?

I would also try to replace squares in distance calculations with absolute values... just to see what happens, but it colud be probably very inaccurate, but can also boost the code.

 

also in:

double RGBEuclidianDistance(rgb &col1, rgb &col2)

I don't see any reason to use doubles, there are just additions and multiplications of unsigned char values.

 

There are also some places where values are divided or multiplied by 2 or 4, where can be used bit shifts instead.

 

Anyway, I don't know how those genetic algorithms work, honestly I don't want to know, but it's fresh great approach I guess. I've also checked generated DLI code which is .... hmm... funny ? There are many LDA #$xx LDX #$xx in row without any STA or STX... I don't know how it generates code but it's really sick :).

Maybe I'm completely wrong, but after million evaluations system tries very tiny changes so if there is major imperfection in image after that many evaluations, it's highly improbable or let's say impossible that it could be fixed in later evaluations.

 

Best Regards,

Martin

Edited by matosimi
Link to comment
Share on other sites

Emkay

 

RastaConvert set LMS per line, it's 57 CPU cycles per line

 

example 9 different values send to register:

 

lda #			 ; change #1 (6 cycle)	 not visible  (out of screen)
sta reg
lda #			 ; change #2 (12 cycle)   not visible  (out of screen)
sta reg
lda #			 ; change #3 (18 cycle)   not visible  (out of screen)   G2F this 3 changes required for EDIT COLORS, EDIT PMG
sta reg
lda #			 ; change #4 (24 cycle)   visible	   this 6 changes is visible in G2F EDIT RASTERS
sta reg
lda #			 ; change #5 (30 cycle)  visible
sta reg
lda #			 ; change #6 (36 cycle)  visible
sta reg
lda #			 ; change #7 (42 cycle)  visible
sta reg
lda #			 ; change #8 (48 cycle)  visible
sta reg
lda #			 ; change #9 (54 cycle)  visible
sta reg

3 cycle free

 

 

more changes, with preload reg A,X,Y

 

lda #
ldx #
ldy #

 

sta reg		; change #1	(4 cycle)	not visible
stx reg		 ; change #2	(8 cycle)
sty reg		 ; change #3	(12 cycle)
lda #		; change #4	(18 cycle)
sta reg

lda #		 ; change #5   (24 cycle)   visible
sta reg
lda #		 ; change #6   (30 cycle)
sta reg
lda #		 ; change #7   (36 cycle)
sta reg
lda #		 ; change #8   (42 cycle)
sta reg
lda #		 ; change #9   (48 cycle)
sta reg
lda #		 ; change #10   (54 cycle)
sta reg

3 cycle free

Link to comment
Share on other sites

I'm trying to look at this from an algorithmic point of view.

 

If we had extra colours on a horizontal line, but certain colours can only be used in specific sections of the line, I can only imagine that the calculations are going to be exponentially difficult (and therefore much much slower).

 

I like the idea of using midline DLIs, but cannot fathom just how much more difficult it will become to code the encoding routine. The extra colours will make life easier, but the locality restrictions of colour use won't help matters.

 

Please though - please prove me wrong with working code. Then maybe it can be ported onto here for some supercomputing... : http://aws.amazon.com/ec2/

Link to comment
Share on other sites

Emkay

 

RastaConvert set LMS per line, it's 57 CPU cycles per line

 

example 9 different values send to register:

 

lda #			 ; change #1 (6 cycle)	 not visible  (out of screen)
sta reg
lda #			 ; change #2 (12 cycle)   not visible  (out of screen)
sta reg
lda #			 ; change #3 (18 cycle)   not visible  (out of screen)   G2F this 3 changes required for EDIT COLORS, EDIT PMG
sta reg
lda #			 ; change #4 (24 cycle)   visible	   this 6 changes is visible in G2F EDIT RASTERS
sta reg
lda #			 ; change #5 (30 cycle)  visible
sta reg
lda #			 ; change #6 (36 cycle)  visible
sta reg
lda #			 ; change #7 (42 cycle)  visible
sta reg
lda #			 ; change #8 (48 cycle)  visible
sta reg
lda #			 ; change #9 (54 cycle)  visible
sta reg

3 cycle free

 

 

more changes, with preload reg A,X,Y

 

lda #
ldx #
ldy #

 

sta reg		; change #1	(4 cycle)	not visible
stx reg		 ; change #2	(8 cycle)
sty reg		 ; change #3	(12 cycle)
lda #		; change #4	(18 cycle)
sta reg

lda #		 ; change #5   (24 cycle)   visible
sta reg
lda #		 ; change #6   (30 cycle)
sta reg
lda #		 ; change #7   (36 cycle)
sta reg
lda #		 ; change #8   (42 cycle)
sta reg
lda #		 ; change #9   (48 cycle)
sta reg
lda #		 ; change #10   (54 cycle)
sta reg

3 cycle free

 

I know .

 

But things would get faster with a - per line examination of used pixels and the dependency with the lines above and below. Possibly a 2 line dither would help with more details though.

 

It would be nice to have a "special feature" in G2F. It shouldn't be too hard to add, I guess.

Just load the original picture for importing and make it possible to have every line "stretched"... and below the same with the same line of the picture to the importing place...

post-2756-0-77991600-1335866836_thumb.gif

 

This one could be analyzed by "view" and directly import by using the preferred details 1st. And, due to the fact, images depend on different scanlines, not all registers need to be changed every scanline, to have the needed colours available.

 

11 colours in the scanline

 

post-2756-0-32835600-1335866838_thumb.jpg

 

10 colours in the scanline

post-2756-0-57308200-1335866837_thumb.jpg

 

 

 

 

9 colours are easily there....

Edited by emkay
Link to comment
Share on other sites

Have a try with my experimental branch.

 

Changes:

 

- Increased pool of available raster cycles from 53 to 55.

- Improved precision of raster program by introducing a neutral 3 cycle CMP 0 instruction.

- Added two experimental mutations: "Copy to Previous Line" and "Shuffle Instructions".

- Applied minor tweaks

RastaConverterMKExpBranch.zip

Edited by Marek Konopka
Link to comment
Share on other sites

Thinking of the best way to use the A8's palette most right.

 

post-2756-0-17958600-1335904527_thumb.jpg

 

 

You know, the left pic is the source, the right is the destination and the middle is the current state.

The colours only were almost available with some shifting of the colours, as you might await a picture like this, which is a quick GTIA 9 Mode edit in G2F....

 

post-2756-0-97577100-1335904520_thumb.jpg

 

This "slight" variation on the used colour balance reduces/removes the dithering-pixels, that would be necessary, to have the sky not just blue....

Edited by emkay
  • Like 1
Link to comment
Share on other sites

Here's a patch to compile this on Linux. Just a few small fixes to make it more standards compliant and a simple Makefile. Did not fix the pathsep issue, but you can just specify the input file and palette file on the command line.

 

Thanks for using portable libraries like allegro and freeimage.

rasta-linux.patch.zip

Edited by ivop
  • Like 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...