Welcome to Fractal Forums

Fractal Art => Images Showcase (Rate My Fractal) => Topic started by: SeryZone on May 02, 2014, 07:58:02 PM




Title: Histogram equalization tests
Post by: SeryZone on May 02, 2014, 07:58:02 PM
Hello to all, who here!
I wrote visualization, thanks for Dunkan C for helping with this idea.

Code:
begin
        index := 0;
        inc(max);
        Histogram := nil; Percentage:=nil;
        SetLength(Histogram, (max-min));
        SetLength(Percentage, (max-min));
        NUM:=0;
        for x:=0 to (maxx*maxy-1) do
          if Iterdat[x]<max then
          inc(Histogram[IterDat[x]-min]);
        //quicks(0, Length(Histogram), Histogram);  //<----------
        for x:=1 to max-min do
          NUM:=NUM+Histogram[x];
        running_total:=0;
        for x:=1 to max-min do
          begin
            running_total := running_total + histogram[x];
            percentage[x] := running_total / NUM;
          end;
          for y := 0 to maxy-1 do
            for x := 0 to maxx-1 do
          begin
            if (IterDat[x*maxy+y] >= max) then
            begin
              buffer[index] := 0; // red
              buffer[index + 1] := 0; // green
              buffer[index + 2] := 0; // blue
            end
            else if (IterDat[x*maxy+y] > 0) and (IterDat[x*Maxy+y]<max) then
              ColorIndex := round( 4096*(percentage[IterDat[x*maxy+y]-min]) ) mod 4096;
            begin
              buffer[index] := pal[ColorIndex].b; // red
              buffer[index + 1] := pal[ColorIndex].g; // green
              buffer[index + 2] := pal[ColorIndex].r; // blue
            end;
            inc(index, 4)
          end;
          dec(max);
      end;

okay, this part have many-many-many bugs, but I don't gave up and made some experiments. How to make rank-ordered list??? If you help me, I will be very glad!

1) I test this part:
Code:
 quicks(0, Length(Histogram), Histogram);  //Sorting Histogram[] array
            ColorIndex := round( 4096*(percentage[IterDat[x*maxy+y]-min]) ) mod 4096;
Result is:

(http://fc03.deviantart.net/fs71/f/2014/122/7/1/histogram_1_by_seryzone-d7gu3hy.jpg)

Reminds to me 'Prodigy' spider, ahaha)))  :D

2) Here, without sort:

(http://fc05.deviantart.net/fs71/f/2014/122/f/4/histogram_2_by_seryzone-d7gu3oy.jpg)

3) Here, I tested squaring:

Code:
ColorIndex := round( 4096*sqr(percentage[IterDat[x*maxy+y]-min]) ) mod 4096;

(http://fc08.deviantart.net/fs71/f/2014/122/c/2/histogram_3_by_seryzone-d7gu3sw.jpg)

Very nice result: lower density and more details!

4) And last low-density test - fourth power:

Code:
ColorIndex := round( 4096*sqr(sqr(percentage[IterDat[x*maxy+y]-min])) ) mod 4096;

(http://fc07.deviantart.net/fs71/f/2014/122/a/c/histogram_4_by_seryzone-d7gu3wv.jpg)

So, If you can help me with solving mistakes - please, help. This equalization very important for me as designer.

P.s. Hope, you rate it...