Any matlab user interested in testing a new screen 2 converter able to place sprites automatically ?

By ARTRAG

Enlighted (6114)

ARTRAG's picture

17-11-2018, 09:42

I'm developing a screen 2 converter that places sprites automatically to fix color spill.
The algorithm is simple but not optimal (anyway may images simply cannot be fixed no matter how optimal is your algorithm) and it is developed as matlab script
I can release it as script, but you need a licensed copy of matlab, or as standalone .exe using the matlab compiler but the user has to install the matlab runtime libraries (free but about 1,3GB of program).

Is there anyone with matlab interested in testing the results of the converter and, eventually, interested in porting it to another framework so to release a simple command line tool ?
I use Codeblocks and gcc but the converter relies on matlab functions that in C should be developed from scratch and I do not know if it is worth the work

a simple test image:
The same picture without and with sprite fix
https://sites.google.com/site/devmsx/home/screen-2-test/basi...
https://sites.google.com/site/devmsx/home/screen-2-test/basi...


Login or register to post comments

By Manuel

Ascended (15195)

Manuel's picture

17-11-2018, 10:02

Does it run in Octave?

By ARTRAG

Enlighted (6114)

ARTRAG's picture

17-11-2018, 11:29

I do no think so, because it depends on rgb2ind and imapprox from the image toolbox that is badly supported in Octave
Anyway that part is mainly for image importation from files, in a different framework they could be replaced

By ARTRAG

Enlighted (6114)

ARTRAG's picture

17-11-2018, 12:21

By ARTRAG

Enlighted (6114)

ARTRAG's picture

18-11-2018, 23:27

Ok the algorithm works under any condition so I did a command line tool in matlab.
For those willing to try, here there are both the .exe and its matlab sources

Sadly, to run the exec you need to install MATLAB Runtime version 9.3 (R2017b)

Instructions about how to install the MATLAB Runtime and how to run the command line are in the readme.txt

By turbor

Champion (415)

turbor's picture

19-11-2018, 00:29

Sounds nice. Are you willing to explain your algorithm here?

By gdx

Prophet (2614)

gdx's picture

19-11-2018, 00:38

I am interested but I do not want to lose 1.3GB on my disk. Do you plan to use another method?
A SC5 to SC2 conversion on MSX would be better.

By ARTRAG

Enlighted (6114)

ARTRAG's picture

19-11-2018, 08:02

turbor wrote:

Sounds nice. Are you willing to explain your algorithm here?

The general idea is simple, look at setsprite.m

It starts from the original image and from its plain screen 2 conversion.
The error between the two images is scanned pixel by pixel counting how many pixels of each color fall in a 16x16 box.
The sprite is set at the position and with the color that guarantee the maximum number of pixels removed from the error image.
This is repeated for each sprite.
There is a line counter per each line, the counters of lines interested by the sprite are increased when the best position is found.
All lines whose counter is bigger than 4 are ignored in the pixel count while scanning the error image for the best sprite position.

By ARTRAG

Enlighted (6114)

ARTRAG's picture

19-11-2018, 09:02

gdx wrote:

I am interested but I do not want to lose 1.3GB on my disk. Do you plan to use another method?
A SC5 to SC2 conversion on MSX would be better.

I could try to replace all the functions not supported by Octave, but its installation is a few GB as well...
The other way is to generate a C source, e.g. using the same Matlab code generator, anyway also in this case many functions I use should be replaced, because not supported. But in this latter case I would release a simple stand alone exe

By ARTRAG

Enlighted (6114)

ARTRAG's picture

25-11-2018, 18:12

All source now is commented and the most of the matlab specific code has been replaced

https://sites.google.com/site/devmsx/home/screen-2-test/scr2...

Anyone with octave willing to try it ?

By ARTRAG

Enlighted (6114)

ARTRAG's picture

27-11-2018, 08:50

Now on github

My MSX profile