Resources and Support
 Pixel Joint Forum : The Lounge : Resources and Support
Message Icon Topic: How do i remove chess patterns from pixel art?? Post Reply Post New Topic
Author Message
bluedxca93
Commander
Commander


Joined: 27 February 2016
Online Status: Offline
Posts: 104
Quote bluedxca93 Replybullet Topic: How do i remove chess patterns from pixel art??
    Posted: 09 January 2014 at 11:08pm
Hello,
Some old icons or bitmaps are using chess patterns for dithering.
is there a way to remove them ???
Have tought that when we have p. ex a b a b a b  as pixels from one 1px height image.
Is there an program who can convert this directly to (delta (a+b)) (delta ((a+b))...
Something like this could quickly remove chess patterns including few more colors to the image. It doesn't need to be precise at edges or lines like these \ .
Has anyone an idea. I don't mean the gimp or photoshop transparency patterns.!
Blurring or down- upscale doesn't help.
regards bluedxca93

IP IP Logged
yrizoud
Commander
Commander
Avatar

Joined: 03 May 2021
Location: France
Online Status: Offline
Posts: 343
Quote yrizoud Replybullet Posted: 10 January 2014 at 4:43am
If you resize to exactly 50% with algorithm "Bilinear filtering" or "Trilinear filtering", it should turn these patterns into flat color which is average of the two colors. You do lose pixel details, however.

Or you may want to try write a script in Grafx2 that examines all 2x2 squares of an image, and if it sees the "grid" pattern, replace all 4 pixels by the average color. It is still imperfect (won't process the "edges" of these patterns), but it can already do a lot of the work.

IP IP Logged
bluedxca93
Commander
Commander


Joined: 27 February 2016
Online Status: Offline
Posts: 104
Quote bluedxca93 Replybullet Posted: 10 January 2014 at 6:42am

Hi,
have tought how an computer program might be able to delete these patterns.
(see graphic)

For one chess pattern:
1) use the 2x2 method an intodruce an new color which isn't in the image palette already. i would name it c.
2) change   c+a+b+a+b and c+b+a+b+a in horizontal and vertical  direction to  c+c+c+c+c
3) change   c+a+b+a and c+b+a+b in horizontal and vertical  direction to  c+c+c+c
4) change   c+a+b and c+b+ain horizontal and vertical  direction to  c+c+c
5) change   c+a and c+b in horizontal and vertical  direction to  c+c
6)  set c to delta a+c.

The steps 4+5 are a bit risky. However an algorith like this would  be better than downscaling. It does some errors, but the chess pattern would begone completly. Some upscaling algorithms or rot sprite have huge problems with these.
Unfortunatly i don't know how to use grafx2 or how to write an standalone pixel shader based app.


Edited by bluedxca93 - 10 January 2014 at 6:43am
IP IP Logged
yrizoud
Commander
Commander
Avatar

Joined: 03 May 2021
Location: France
Online Status: Offline
Posts: 343
Quote yrizoud Replybullet Posted: 10 January 2014 at 11:58am
I've just made a script for Grafx2, it auto-detects patterns by the presence of 2x2 block with any colors in pattern:
OX
XO
It makes the average, and then tries to expand on the 8 surrounding pixels.
Here is the result for your icon:

As you can see, it can mistakenly affect small pixels like the P and N letters.

    -- Remove dither pattern
     
    w, h = getbrushsize()
     
    for y = 0, h - 2, 1 do
     
      for x = 0, w - 2, 1 do
       
        c1 = getbrushbackuppixel(x,y);
        c2 = getbrushbackuppixel(x+1,y);
        c3 = getbrushbackuppixel(x,y+1);
        c4 = getbrushbackuppixel(x+1,y+1);
       
        if (c1 == c4) and (c2 == c3) then
          r1, g1, b1 = getcolor(c1);
          r2, g2, b2 = getcolor(c2);
         
         
          avgcol = matchcolor((r1+r2)/2, (g1+g2)/2, (b1+b2)/2)
         
          putbrushpixel(x, y, avgcol);
          putbrushpixel(x+1, y, avgcol);
          putbrushpixel(x, y+1, avgcol);
          putbrushpixel(x+1, y+1, avgcol);
         
          -- expand on all 4 directions
          if (getbrushbackuppixel(x-1,y) == c2) then
            putbrushpixel(x-1, y, avgcol);
          end
          if (getbrushbackuppixel(x,y-1) == c2) then
            putbrushpixel(x, y-1, avgcol);
          end
          if (getbrushbackuppixel(x+1,y-1) == c1) then
            putbrushpixel(x+1, y-1, avgcol);
          end
          if (getbrushbackuppixel(x+2,y) == c1) then
            putbrushpixel(x+2, y, avgcol);
          end
          if (getbrushbackuppixel(x+2,y+1) == c2) then
            putbrushpixel(x+2, y+1, avgcol);
          end
          if (getbrushbackuppixel(x+1,y+2) == c2) then
            putbrushpixel(x+1, y+2, avgcol);
          end
          if (getbrushbackuppixel(x,y+2) == c1) then
            putbrushpixel(x, y+2, avgcol);
          end
          if (getbrushbackuppixel(x-1,y+1) == c1) then
            putbrushpixel(x-1, y+1, avgcol);
          end
        end
      end
    end




Edited by yrizoud - 10 January 2014 at 12:00pm
IP IP Logged
bluedxca93
Commander
Commander


Joined: 27 February 2016
Online Status: Offline
Posts: 104
Quote bluedxca93 Replybullet Posted: 11 January 2014 at 12:55am
Hi,
Good thing It works !
The bad thing is, that i don't know how to apply it without copy the image before in some strange selct/brush image buffer.
But that isn`t that important.
I think i understand now how the scripting thing works.
If i can  make  an better script I will post it.

The average colors it produces are really nice . It is fast and produce nearly perfect ouput.

regards bluedxca93.

IP IP Logged
yrizoud
Commander
Commander
Avatar

Joined: 03 May 2021
Location: France
Online Status: Offline
Posts: 343
Quote yrizoud Replybullet Posted: 11 January 2014 at 3:14am
In the script you can replace "brush" by "picture" everywhere; I used the brush because I found it easier to compare with the original.

Also when the script determines the average color, there's no guarantee the current image palette has a very good candidate.
If you're converting 16-color icons, I could make it first fill palette entries >16 with the color combinations.
Can you post one or two other sample images I can test with ?

IP IP Logged
bluedxca93
Commander
Commander


Joined: 27 February 2016
Online Status: Offline
Posts: 104
Quote bluedxca93 Replybullet Posted: 11 January 2014 at 6:51am
hi,
on my grafx2 version getbackuppicturepixel doesn't work.
How do i intodruce the new colors in the palette?
Have tested an 4x1 pattern which works well on images like these:
http://www.goodolddays.net/game/id,416/lang,de/%C3%96kolopoly.html
I would try to improve it.

regards bluedxca93



Edited by bluedxca93 - 11 January 2014 at 6:56am
IP IP Logged
bluedxca93
Commander
Commander


Joined: 27 February 2016
Online Status: Offline
Posts: 104
Quote bluedxca93 Replybullet Posted: 11 January 2014 at 7:31am
Have found the bug:
getbackuppicturepixel is named getbackuppixel in reality.
Here my 1x4 script ( only at the moment, I will add y correction).
I also think that i could improve your 2x2 script.
This script does alrady a lot on big pictures.
Please tell me how to add the new colors to the palette.

-- Remove dither pattern with 1x4 horzontal method and slight 1px vertcal support.--
 
w, h = getpicturesize()
 
for y = 0, h - 1, 1 do
 
  for x = 0, w - 4, 1 do
  
c1 = getbackuppixel(x,y);
c2 = getbackuppixel(x+1,y);
c3 = getbackuppixel(x+2,y);
c4 = getbackuppixel(x+3,y);
  
if (c1 == c3) and (c2 == c4) then
  r1, g1, b1 = getcolor(c1);
  r2, g2, b2 = getcolor(c2);
 
 
  avgcol = matchcolor((r1+r2)/2, (g1+g2)/2, (b1+b2)/2)
 
  putpicturepixel(x, y, avgcol);
  putpicturepixel(x+1, y, avgcol);
  putpicturepixel(x+2, y, avgcol);
  putpicturepixel(x+3, y, avgcol);

-- expand on all 4 directions up --
  if (getbackuppixel(x,y+1) == c2) and (getbackuppixel(x+1,y+1) == c1) then
putpicturepixel(x, y+1, avgcol);
  end
  if (getbackuppixel(x+1,y+1) == c1) and (getbackuppixel(x+2,y+1) == c2) then
putpicturepixel(x+1, y+1, avgcol);
  end
  if (getbackuppixel(x+2,y+1) == c2) and (getbackuppixel(x+3,y+1) == c1) then
putpicturepixel(x+2, y+1, avgcol);
  end
  if (getbackuppixel(x+3,y+1) == c1) and  (getbackuppixel(x+4,y+1) == c2) then
putpicturepixel(x+3, y+1, avgcol);
  end
-- expand on all 4 directions down --
  if (getbackuppixel(x,y-1) == c2) and (getbackuppixel(x+1,y-1) == c1) then
putpicturepixel(x, y-1, avgcol);
  end
  if (getbackuppixel(x+1,y-1) == c1) and (getbackuppixel(x+2,y-1) == c2) then
putpicturepixel(x+1, y-1, avgcol);
  end
  if (getbackuppixel(x+2,y-1) == c2) and (getbackuppixel(x+3,y-1) == c1) then
putpicturepixel(x+2, y-1, avgcol);
  end
  if (getbackuppixel(x+3,y-1) == c1) and (getbackuppixel(x+4,y-1) == c2) then
putpicturepixel(x+3, y-1, avgcol);
  end
end
  end
end


Edited by bluedxca93 - 11 January 2014 at 8:25am
IP IP Logged
yrizoud
Commander
Commander
Avatar

Joined: 03 May 2021
Location: France
Online Status: Offline
Posts: 343
Quote yrizoud Replybullet Posted: 11 January 2014 at 11:45am
Sorry about the syntax :/ Here's a script that affects the image directly.
It's specialized to work on 16-color images such as those screenshots from Hi-res VGA images (640x400 16col), so before running script you should first open Palette menu and choose Reduce - to 16.
-- Remove dither pattern
--
--

-- Determines which color should store the average of colors i and j.
-- Only works if i and j are different and both < 16.
function transp(i, j)
  if i < j then
    return i*15+j+15
  else
    return j*15+i+15
  end
end

w, h = getpicturesize()

for i = 0, 15 do
  for j = i+1, 15 do
    r1, g1, b1 = getcolor(i);
    r2, g2, b2 = getcolor(j);
   
    setcolor(transp(i,j), (r1+r2) / 2, (g1+g2) / 2, (b1+b2) / 2)
  end
end

for y = 0, h - 2, 1 do

  for x = 0, w - 2, 1 do
   
    -- Pixels:
    --
    -- c1 c2
    -- c3 c4
    --
   
    c1 = getbackuppixel(x,y);
    c2 = getbackuppixel(x+1,y);
   
    if (c1 ~= c2) and (c1<16) and (c2<16) then
     
      c3 = getbackuppixel(x,y+1);
      c4 = getbackuppixel(x+1,y+1);
     
      if (c1 == c4) and (c2 == c3) then
        avgcol = transp(c1, c2)
       
        putpicturepixel(x, y, avgcol);
        putpicturepixel(x+1, y, avgcol);
        putpicturepixel(x, y+1, avgcol);
        putpicturepixel(x+1, y+1, avgcol);
       
        -- expand on all 4 directions
        if (getbackuppixel(x-1,y) == c2) then
          putpicturepixel(x-1, y, avgcol);
        end
        if (getbackuppixel(x,y-1) == c2) then
          putpicturepixel(x, y-1, avgcol);
        end
        if (getbackuppixel(x+1,y-1) == c1) then
          putpicturepixel(x+1, y-1, avgcol);
        end
        if (getbackuppixel(x+2,y) == c1) then
          putpicturepixel(x+2, y, avgcol);
        end
        if (getbackuppixel(x+2,y+1) == c2) then
          putpicturepixel(x+2, y+1, avgcol);
        end
        if (getbackuppixel(x+1,y+2) == c2) then
          putpicturepixel(x+1, y+2, avgcol);
        end
        if (getbackuppixel(x,y+2) == c1) then
          putpicturepixel(x, y+2, avgcol);
        end
        if (getbackuppixel(x-1,y+1) == c1) then
          putpicturepixel(x-1, y+1, avgcol);
        end
      end
    end
  end
end

IP IP Logged
bluedxca93
Commander
Commander


Joined: 27 February 2016
Online Status: Offline
Posts: 104
Quote bluedxca93 Replybullet Posted: 14 January 2014 at 12:10am
Hi,
Have now written an nearly perfect chess pattern remover =) . It is based on some complex predefined patterns. It works well, and i would still improve the algorithm a bit. It produces different output when you rotate the image. . I have tried with 2x2 approach like yours but this causes some problems with letters like N in bitmap fonts and some other things.

Isn't it possible to add the missing the colors to the palette and then using avgcolor?

I think i can post this in the forum as text, but how do i attach files for biiger scripts. ??

-- Remove dither pattern with horizontal approach - 1 pixel up and own supportedd- will add this for two in future---

w, h = getpicturesize()

for y = 0, h - 1, 1 do

for x = 0, w - 4, 1 do
   
c1 = getbackuppixel(x,y);
c2 = getbackuppixel(x+1,y);
c3 = getbackuppixel(x+2,y);
c4 = getbackuppixel(x+3,y);
   
if (c1 == c3) and (c2 == c4) and (c1 ~= c2) and (c2 ~= c3) and (getbackuppixel(x,y+1) ~= c1) and (getbackuppixel(x+2,y+1) ~= c1) and (getbackuppixel(x,y-1) ~= c1) and (getbackuppixel(x+2,y-1) ~= c1) then
r1, g1, b1 = getcolor(c1);
r2, g2, b2 = getcolor(c2);


avgcol = matchcolor((r1+r2)/2, (g1+g2)/2, (b1+b2)/2)

putpicturepixel(x, y, avgcol);
putpicturepixel(x+1, y, avgcol);
putpicturepixel(x+2, y, avgcol);
putpicturepixel(x+3, y, avgcol);

-- expand on all 4 directions up --
    if (getbackuppixel(x,y+1) == c2) and (getbackuppixel(x+1,y+1) ~= c2) and (getbackuppixel(x-1,y+1) ~= c2) and ((getbackuppixel(x+1,y+1) == c1) or (getbackuppixel(x-1,y+1) == c1)) then
putpicturepixel(x, y+1, avgcol);
end
if (getbackuppixel(x+1,y+1) == c1) and (getbackuppixel(x+2,y+1) ~= c1) and (getbackuppixel(x,y+1) ~= c1) and ((getbackuppixel(x+2,y+1) == c2) or (getbackuppixel(x,y+1) == c2)) then
putpicturepixel(x+1, y+1, avgcol);
end
if (getbackuppixel(x+2,y+1) == c2) and (getbackuppixel(x+3,y+1) ~= c2) and (getbackuppixel(x+1,y+1) ~= c2) and ((getbackuppixel(x+3,y+1) == c1) or (getbackuppixel(x+1,y+1) == c1)) then
putpicturepixel(x+2, y+1, avgcol);
end
if (getbackuppixel(x+3,y+1) == c1) and (getbackuppixel(x+4,y+1) ~= c1) and (getbackuppixel(x+2,y+1) ~= c1) and ((getbackuppixel(x+4,y+1) == c2) or (getbackuppixel(x+2,y+1) == c2)) then
putpicturepixel(x+3, y+1, avgcol);
end
-- expand on all 4 directions down --
    if (getbackuppixel(x,y-1) == c2) and (getbackuppixel(x+1,y-1) ~= c2) and (getbackuppixel(x-1,y-1) ~= c2) and ((getbackuppixel(x+1,y-1) == c1) or (getbackuppixel(x-1,y-1) == c1)) then
putpicturepixel(x, y-1, avgcol);
end
if (getbackuppixel(x+1,y-1) == c1) and (getbackuppixel(x+2,y-1) ~= c1) and (getbackuppixel(x,y-1) ~= c1) and ((getbackuppixel(x+2,y-1) == c2) or (getbackuppixel(x,y-1) == c2)) then
putpicturepixel(x+1, y-1, avgcol);
end
if (getbackuppixel(x+2,y-1) == c2) and (getbackuppixel(x+3,y-1) ~= c2) and (getbackuppixel(x+1,y-1) ~= c2) and ((getbackuppixel(x+3,y-1) == c1) or (getbackuppixel(x+1,y-1) == c1)) then
putpicturepixel(x+2, y-1, avgcol);
end
if (getbackuppixel(x+3,y-1) == c1) and (getbackuppixel(x+4,y-1) ~= c1) and (getbackuppixel(x+2,y-1) ~= c1) and ((getbackuppixel(x+4,y-1) == c2) or (getbackuppixel(x+2,y-1) == c2)) then
putpicturepixel(x+3, y-1, avgcol);
end
end
end
end

-- Remove left dither pattern with 4x1 vertical. Contains some important if then else conditions, so that it won't progress non chess patterns.--

w, h = getpicturesize()

for y = 0, h - 4, 1 do

for x = 0, w - 1, 1 do
   
c1 = getbackuppixel(x,y);
c2 = getbackuppixel(x,y+1);
c3 = getbackuppixel(x,y+2);
c4 = getbackuppixel(x,y+3);
   
if (c1 == c3) and (c2 == c4) and (c1 ~= c2) and (c2 ~= c3) and (getbackuppixel(x+1,y) ~= c1) and (getbackuppixel(x+1,y+1) ~= c2) and (getbackuppixel(x+1,y+2) ~= c3) and (getbackuppixel(x+1,y+3) ~= c4) and (getbackuppixel(x-1,y) ~= c1) and (getbackuppixel(x-1,y+1) ~= c2) and (getbackuppixel(x-1,y+2) ~= c3) and (getbackuppixel(x-1,y+3) ~= c4) and (getbackuppixel(x,y+4) ~=c4) and (getbackuppixel(x,y-1) ~=c1) then
r1, g1, b1 = getcolor(c1);
r2, g2, b2 = getcolor(c2);


avgcol = matchcolor((r1+r2)/2, (g1+g2)/2, (b1+b2)/2)

putpicturepixel(x, y, avgcol);
putpicturepixel(x, y+1, avgcol);
putpicturepixel(x, y+2, avgcol);
putpicturepixel(x, y+3, avgcol);

-- expand on all 4 directions up --
if (getbackuppixel(x+1,y) == c2) and (getbackuppixel(x+1,y+1) == c1) then
putpicturepixel(x+1, y, avgcol);
end
if (getbackuppixel(x+1,y+1) == c1) and (getbackuppixel(x+1,y+2) == c2) then
putpicturepixel(x+1, y+1, avgcol);
end
if (getbackuppixel(x+1,y+2) == c2) and (getbackuppixel(x+1,y+3) == c1) then
putpicturepixel(x+1, y+2, avgcol);
end
if (getbackuppixel(x+1,y+3) == c1) and (getbackuppixel(x+1,y+4) == c2) then
putpicturepixel(x+1, y+3, avgcol);
end
-- expand on all 4 directions down --
    if (getbackuppixel(x-1,y) == c2) and (getbackuppixel(x-1,y+1) == c1) then
putpicturepixel(x-1, y, avgcol);
end
if (getbackuppixel(x-1,y+1) == c1) and (getbackuppixel(x-1,y+2) == c2) then
putpicturepixel(x-1, y+1, avgcol);
end
if (getbackuppixel(x-1,y+2) == c2) and (getbackuppixel(x-1,y+3) == c1) then
putpicturepixel(x-1, y+2, avgcol);
end
if (getbackuppixel(x-1,y+3) == c1) and (getbackuppixel(x-1,y+4) == c2) then
putpicturepixel(x-1, y+3, avgcol);
end
end
end
end
IP IP Logged
DawnBringer
Commander
Commander
Avatar

Joined: 11 August 2024
Online Status: Offline
Posts: 568
Quote DawnBringer Replybullet Posted: 14 January 2014 at 1:43am
A tip: You can assign a function to a "variable", like gp = getbackuppixel then use gp(x,y) instead. This will shorten the code and make it more dynamic as you can easily reassign equivalent brush functions.
IP IP Logged
neota
Commander
Commander
Avatar

Joined: 27 November 2018
Online Status: Offline
Posts: 158
Quote neota Replybullet Posted: 14 January 2014 at 5:02am
I think i can post this in the forum as text, but how do i attach files for biiger scripts. ??


Pastebin it instead, and give us the link. http://bpaste.net is my preferred pastebin-like service, personally.
If you take the time to select the language being used, you also get syntax highlighting, which is very useful if you expect others to read your code.
absolutely.
IP IP Logged
yrizoud
Commander
Commander
Avatar

Joined: 03 May 2021
Location: France
Online Status: Offline
Posts: 343
Quote yrizoud Replybullet Posted: 14 January 2014 at 11:17am
Here's your script where I added the palette modification. I improved the computation of "average" by taking into account gamma correction, thanks to DawnBringer for quick answer to my gamma questions :)
http://bpaste.net/show/y0dTuTVRXdCwDhGwfa0c/
An example of result (animation before/after):



Edited by yrizoud - 14 January 2014 at 11:17am
IP IP Logged
Different55
Seaman
Seaman
Avatar

Joined: 22 July 2019
Online Status: Offline
Posts: 13
Quote Different55 Replybullet Posted: 14 January 2014 at 2:42pm
In some places it ends up blurring vertical lines, most noticeably in the tower in the left and and the train car in the right. In other places it turns light, 1px wide lines into dashed lines, like in the bottom right corner. It's averaging the color of the pixels at that white spot in the trees at the very left side. Overall it's looking pretty good.
IP IP Logged
bluedxca93
Commander
Commander


Joined: 27 February 2016
Online Status: Offline
Posts: 104
Quote bluedxca93 Replybullet Posted: 14 January 2014 at 11:19pm
Yes, the vertical line algorith is really only average .
But i have  some ideas to fix this. I would also try to set an variable for getbackuppixel 'cause the lines are sometimes longer than my screen resolutions, so that i don't see the line breaks anymore XD. It works amazingly well on small 32x32  bitmaps too.  Patterns like these:  ababab could still be affected wrongly sometimes.But not often!.  As you can see the w and m pattern are not affected by the algorithm.
yirzoud/DawnBringer  thanks for your help with the color palettes issues.
And also thaks to  neota  for the pastebin tip.

Can i use the linux text */ */ highlighting in grafx2 scripts?

regards bluedxca93



IP IP Logged
neota
Commander
Commander
Avatar

Joined: 27 November 2018
Online Status: Offline
Posts: 158
Quote neota Replybullet Posted: 14 January 2014 at 11:37pm
^ If you use a programmers editor -- for example, I use Geany, and also Editra.. then you will get syntax highlighting for most common languages (that typically includes Lua). I am guessing at what you meant by
Can i use the linux text */ */ highlighting in grafx2 scripts?

.. I think you were trying to ask about syntax highlighting in your editor.

If you are talking about C-style block comments instead,
see this information about Lua block comments (the relevant info is at the bottom of the page).

In either case, these things are not especially associated with Linux; You can do them on any operating system.




Edited by neota - 14 January 2014 at 11:53pm
absolutely.
IP IP Logged
bluedxca93
Commander
Commander


Joined: 27 February 2016
Online Status: Offline
Posts: 104
Quote bluedxca93 Replybullet Posted: 15 January 2014 at 4:21am
Yeah, you are right. I forget sometimes that you can do compile programs or run scripts with windows too. After w2k i didn't use it very much (except some programs inside wine) .

I use the  simple texteditor gedit and sometimes meld for comparision of texts. And thanks for the link.

 `ve noticed, that the current algorithm has problems with 2 color bitmaps.
IP IP Logged
bluedxca93
Commander
Commander


Joined: 27 February 2016
Online Status: Offline
Posts: 104
Quote bluedxca93 Replybullet Posted: 17 January 2014 at 6:14am
Method 1 : http://pastebin.com/72ECfysR
Method 2 : http://pastebin.com/UBJuh38x

Both Methods do  remove chess pattern. However the result will differ. I can't say which method is better, it depends on the image size the art of the image and other things.

WARNING: It won't work on Black/White images very well. Those images would require an entire different algorithm logic. Processing p.ex 640x480 16 color images may still take some time but  i think that black and white images would take much more time. ( The filter logic would be really complex for 2 color images.).

IP IP Logged
DawnBringer
Commander
Commander
Avatar

Joined: 11 August 2024
Online Status: Offline
Posts: 568
Quote DawnBringer Replybullet Posted: 22 January 2014 at 2:47am
Btw. Dividing and multiplying with 255 is redundant in the gamma-correction.
IP IP Logged
bluedxca93
Commander
Commander


Joined: 27 February 2016
Online Status: Offline
Posts: 104
Quote bluedxca93 Replybullet Posted: 22 January 2014 at 4:06am
That is true, but i didn't really looked at this part of the lua script code. The code works a bit slow, but not too slow =).
I Have also tried to implement something like this script whith imagemagick but it seems to be impossible.
IP IP Logged
neota
Commander
Commander
Avatar

Joined: 27 November 2018
Online Status: Offline
Posts: 158
Quote neota Replybullet Posted: 22 January 2014 at 5:59am
You might be able to implement it using GMIC instead:

http://gmic.sourceforge.net/
absolutely.
IP IP Logged
yrizoud
Commander
Commander
Avatar

Joined: 03 May 2021
Location: France
Online Status: Offline
Posts: 343
Quote yrizoud Replybullet Posted: 22 January 2014 at 8:02am
Btw. Dividing and multiplying with 255 is redundant in the gamma-correction.
That is true, but i didn't really looked at this part of the lua script code.

This critic was directed at me :) I'm really bad at detecting when f(x*N) == f(x)*N
To my defense, this part is called only 136 times, no matter the image size.

Bluedxca93 : Do you have a lot of images to convert ? So far you seem to have spent a lot of time on this.
IP IP Logged
bluedxca93
Commander
Commander


Joined: 27 February 2016
Online Status: Offline
Posts: 104
Quote bluedxca93 Replybullet Posted: 23 January 2014 at 6:58am
136 times is not much.
Gmic is to complicated for me.
Have tried now gluas.  I think i will get an working version  soon. Perhaps this will also improve the grafx2 script.

Not really, i want to upscale some 32x32 or 48x48  pixmaps with chess patterns. And it takes some time to edit every bitmap before upscaling.
IP IP Logged
yrizoud
Commander
Commander
Avatar

Joined: 03 May 2021
Location: France
Online Status: Offline
Posts: 343
Quote yrizoud Replybullet Posted: 23 January 2014 at 7:06am
For mass conversion, I'd use :
imagemagick for mass conversion into 16 colors (single command line)
In grafx2:
Assign a keyboard shortcut to the script, like Alt-R for example.
For each file:
   F3 (select file) enter
   Alt-R
   Shift F2
Repeat

IP IP Logged
Post Reply Post New Topic
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum