Jump to content

Search the Community

Showing results for tags 'floyd-steinberg'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • General
    • Announcements and Site News
    • Administration
  • AutoIt v3
    • AutoIt Help and Support
    • AutoIt Technical Discussion
    • AutoIt Example Scripts
  • Scripting and Development
    • Developer General Discussion
    • Language Specific Discussion
  • IT Administration
    • Operating System Deployment
    • Windows Client
    • Windows Server
    • Office

Categories

  • AutoIt Team
    • Beta
    • MVP
  • AutoIt
    • Automation
    • Databases and web connections
    • Data compression
    • Encryption and hash
    • Games
    • GUI Additions
    • Hardware
    • Information gathering
    • Internet protocol suite
    • Maths
    • Media
    • PDF
    • Security
    • Social Media and other Website API
    • Windows
  • Scripting and Development
  • IT Administration
    • Operating System Deployment
    • Windows Client
    • Windows Server
    • Office

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Member Title


Location


WWW


Interests

Found 1 result

  1. I'm trying to make a 1bit (two colors) floyd-steinberg dithering on images but I'm getting artifacts/blemishes, I have tried hundreds of permutations so now I have to ask you guys if you can spot the mistake(s). Pseudo code from Wikipedia... https://en.wikipedia.org/wiki/Floyd–Steinberg_dithering My code... #include<GDIPlus.au3> HotKeySet("{ESC}", "_exit") _GDIPlus_Startup() Global $Image = _GDIPlus_BitmapCreateFromFile ("graytest.png") Global $Width = _GDIPlus_ImageGetWidth($Image), $Height = _GDIPlus_ImageGetHeight($Image) $Gui= GUICreate("Floyd-Steinberg Dithering", $Width, $Height) GUISetState() $Graphics = _GDIPlus_GraphicsCreateFromHWND($Gui) _GDIPlus_GraphicsDrawImageRect ($Graphics,$Image, 0, 0, $Width, $Height) For $y = 0 To $Height - 1 For $x = 0 To $Width - 1 $oldpixel = Dec(Hex(_GDIPlus_BitmapGetPixel($Image, $X, $Y), 2)) $newpixel = Round($oldpixel / 255) ? 0 : 1; _GDIPlus_BitmapSetPixel($Image, $X, $Y, String("0xFF" & Hex($newpixel*255, 2) & Hex($newpixel*255, 2) & Hex($newpixel*255, 2))) $quant_error = $oldpixel - $newpixel ;~ Consolewrite($quant_error & " " & @crlf) ;-------Floyd-Steinberg _GDIPlus_BitmapSetPixel($Image, $X+1, $Y, _GDIPlus_BitmapGetPixel($Image, $X+1, $Y ) + 7/16 * $quant_error) _GDIPlus_BitmapSetPixel($Image, $X-1, $Y+1, _GDIPlus_BitmapGetPixel($Image, $X-1, $Y+1) + 3/16 * $quant_error) _GDIPlus_BitmapSetPixel($Image, $X, $Y+1, _GDIPlus_BitmapGetPixel($Image, $X, $Y+1) + 5/16 * $quant_error) _GDIPlus_BitmapSetPixel($Image, $X+1, $Y+1, _GDIPlus_BitmapGetPixel($Image, $X+1, $Y+1) + 1/16 * $quant_error) ;-------Sierra2 ;~ _GDIPlus_BitmapSetPixel($Image, $X+1, $Y , _GDIPlus_BitmapGetPixel($Image, $X+1, $Y ) + 4/16 * $quant_error) ;~ _GDIPlus_BitmapSetPixel($Image, $X+2, $Y , _GDIPlus_BitmapGetPixel($Image, $X+2, $Y ) + 3/16 * $quant_error) ;~ _GDIPlus_BitmapSetPixel($Image, $X-1, $Y+1, _GDIPlus_BitmapGetPixel($Image, $X-1, $Y+1) + 1/16 * $quant_error) ;~ _GDIPlus_BitmapSetPixel($Image, $X, $Y+1, _GDIPlus_BitmapGetPixel($Image, $X, $Y+1) + 2/16 * $quant_error) ;~ _GDIPlus_BitmapSetPixel($Image, $X+1, $Y+1, _GDIPlus_BitmapGetPixel($Image, $X+1, $Y+1) + 3/16 * $quant_error) ;~ _GDIPlus_BitmapSetPixel($Image, $X+2, $Y+1, _GDIPlus_BitmapGetPixel($Image, $X+2, $Y+1) + 2/16 * $quant_error) ;~ _GDIPlus_BitmapSetPixel($Image, $X+3, $Y+1, _GDIPlus_BitmapGetPixel($Image, $X+3, $Y+1) + 1/16 * $quant_error) Next _GDIPlus_GraphicsDrawImageRect($Graphics, $Image, 0, 0, $Width, $Height); to see the errors quick instead of waiting for the whole image Next _GDIPlus_GraphicsDrawImageRect($Graphics, $Image, 0, 0, $Width, $Height) While GUIGetMsg <> - 3 Sleep(10) WEnd Func _exit() Exit EndFunc ;-------------------------------------------------------------------------------------------------------------- ;~ from Wikipedia article https://en.wikipedia.org/wiki/Floyd%E2%80%93Steinberg_dithering ;~ for each y from top to bottom ;~ for each x from left to right ;~ oldpixel := pixel[x][y] ;~ newpixel := find_closest_palette_color(oldpixel) ;~ pixel[x][y] := newpixel ;~ quant_error := oldpixel - newpixel ;~ pixel[x+1][y ] := pixel[x+1][y ] + 7/16 * quant_error ;~ pixel[x-1][y+1] := pixel[x-1][y+1] + 3/16 * quant_error ;~ pixel[x ][y+1] := pixel[x ][y+1] + 5/16 * quant_error ;~ pixel[x+1][y+1] := pixel[x+1][y+1] + 1/16 * quant_error ;~ find_closest_palette_color(oldpixel) = round(oldpixel / 255) ;-------------------------------------------------------------------------------------------------------------- If you comment the floyd-steinberg lines and uncomment the Sierra2 lines you can see that's much better without artifacts in the middle of the images, though it still has artifacts on the left side of the image, but it's mostly floyd I need working, any help? (dont mind the slow gdi+, I'll be using struct or c-dll when/if i get it working.) /edit, forgot the pic, but try with any pic /edit2, I will only be feeding it 8bit grayscale images)
×
×
  • Create New...