-
Posts
1,028 -
Joined
-
Last visited
-
Days Won
31
Werty last won the day on January 23
Werty had the most liked content!
About Werty
- Currently Viewing Forums Index
Profile Information
-
Member Title
♥ 96.7k
-
Location
Danmark
Recent Profile Visitors
Werty's Achievements
-
Trouble with Floyd-Steinberg dithering
Werty replied to Werty's topic in AutoIt General Help and Support
That's more like it. now I get... Eagle 1785 Face 1690- 19 replies
-
- dithering
- floyd-steinberg
-
(and 1 more)
Tagged with:
-
Trouble with Floyd-Steinberg dithering
Werty replied to Werty's topic in AutoIt General Help and Support
Earlier i adjusted this part... Select Case fGreys Case 0.05 To 0.18 iB = 1 Case 0.19 To 0.34 iG = 1 Case 0.35 To 0.50 iB = 1 iG = 1 Case 0.51 To 0.66 iR = 1 Case 0.67 To 0.82 iR = 1 iB = 1 Case 0.83 To 0.95 iR = 1 iG = 1 End Select ..to use only 2 decimal places, if the decimal places are longer than 2 it misses some going from case to case, scroll up and see the changes.- 19 replies
-
- dithering
- floyd-steinberg
-
(and 1 more)
Tagged with:
-
Trouble with Floyd-Steinberg dithering
Werty replied to Werty's topic in AutoIt General Help and Support
Nice, how does the code look in freebasic, not that I'm gonna start with freebasic, just curious. I noticed we dont get same results, I take it you didnt use LUMA but the " (iR * 213 + iG * 715 + iB * 72) / 1000" you mentioned, quite a difference, i get... Eagle.jpg: yours 1020 grays, mine 1654 Face, png: yours 978, mine 1576 Maybe a switch parameter where the user can select between "Average", "LUMA", "Yours" and whatever other there might be.- 19 replies
-
- dithering
- floyd-steinberg
-
(and 1 more)
Tagged with:
-
Trouble with Floyd-Steinberg dithering
Werty replied to Werty's topic in AutoIt General Help and Support
If it was a question then sure, please go ahead.- 19 replies
-
- dithering
- floyd-steinberg
-
(and 1 more)
Tagged with:
-
Werty reacted to a post in a topic: Trouble with Floyd-Steinberg dithering
-
Trouble with Floyd-Steinberg dithering
Werty replied to Werty's topic in AutoIt General Help and Support
How about going the other way, more than 256 grays... Guess how many grays this image has. Or make your own... #Include <GDIPlus.au3> HotKeySet("{ESC}", "_exit") _GDIPlus_Startup() $Image = _GDIPlus_BitmapCreateFromFile("image.png") $Width = _GDIPlus_ImageGetWidth($Image) $Height = _GDIPlus_ImageGetHeight($Image) $GUI = GUICreate("AmazingGrays", $Width, $Height);, -1, -1) GUISetState() $Graphics = _GDIPlus_GraphicsCreateFromHWND($Gui) _GDIPlus_GraphicsDrawImageRect ($Graphics,$Image, 0, 0, $Width, $Height) $Bitmap = _GDIPlus_BitmapLockBits($Image, 0, 0, $Width, $Height, BitOR($GDIP_ILMWRITE, $GDIP_ILMREAD), $GDIP_PXF32ARGB) $Pixels = DllStructCreate("dword[" & $Width * $Height & "];", DllStructGetData($Bitmap, "Scan0")) For $Loop = 1 To $Width * $Height $Pixel = DllStructGetData($Pixels, 1, $Loop) $Red = Dec(StringMid(Hex($Pixel, 6), 1, 2)) $Green = Dec(StringMid(Hex($Pixel, 6), 3, 2)) $Blue = Dec(StringMid(Hex($Pixel, 6), 5, 2)) Local $R = 0, $G = 0, $B = 0 $LUMA = (($Red*.3) + ($Green*.59) + ($Blue*.11)/3) $AGrays = $LUMA - Int($LUMA) $LUMA = Int($LUMA) Switch StringFormat("%.2f", $AGrays) Case .05 To .18 $B = 1 Case .19 To .34 $G = 1 Case .35 To .50 $B = 1 $G = 1 Case .51 To .66 $R = 1 Case .67 To .82 $R = 1 $B = 1 Case .83 To .95 $R = 1 $G = 1 EndSwitch DllStructSetData($Pixels, 1, "0xFF" & Hex($LUMA + $R, 2) & Hex($LUMA + $G, 2) & Hex($LUMA + $B, 2), $Loop) Next _GDIPlus_BitmapUnlockBits($Image, $Bitmap) _GDIPlus_GraphicsDrawImageRect($Graphics, $Image, 0, 0, $Width, $Height) Do Until GUIGetMsg() = - 3 Func _exit() Exit EndFunc It's using "near gray" colors, like (155,155,154) looks gray eventhough it's not pure, also called "pseudo gray" or "fake gray", good for photographers that wanna print high resolution images as grayscale on big posters. /edit Comparison between standard averaging on the left that came to 246 grays and AmazingGrays on the right came to 1512 grays.- 19 replies
-
- dithering
- floyd-steinberg
-
(and 1 more)
Tagged with:
-
Trouble with Floyd-Steinberg dithering
Werty replied to Werty's topic in AutoIt General Help and Support
Thanks, awesome work as usual, unfortunately I know nothing about freebasic and kinda need it to be "my own" code, with help and inspiration from others ofcourse, this is just a small part of a bigger project, but I will certainly be using it till I get around to attempting making a c-dll, that will include other stuff also, I've just been busy with other parts after getting this atleast working so I could get on with other stuff. But damn it's fast.- 19 replies
-
- dithering
- floyd-steinberg
-
(and 1 more)
Tagged with:
-
Danyfirex reacted to a post in a topic: Trouble with Floyd-Steinberg dithering
-
Trouble with Floyd-Steinberg dithering
Werty replied to Werty's topic in AutoIt General Help and Support
I put the image in a struct and looped the dither stuff, faster but no preview. #include <GDIPlus.au3> HotKeySet("{ESC}", "_exit") _GDIPlus_Startup() Global $Floyd[12] = [7, 3, 5, 1, 1, -1, 0, 1, 0, 1, 1, 1] 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) $Bitmap1 = _GDIPlus_BitmapLockBits($Image, 0, 0, $Width, $Height, BitOR($GDIP_ILMWRITE, $GDIP_ILMREAD), $GDIP_PXF32ARGB) $Pixels1 = DllStructCreate("dword[" & $Width * $Height & "];", DllStructGetData($Bitmap1, "Scan0")) $floatstruct = DllStructCreate("float") $dwordstruct = DllStructCreate("dword", DllStructGetPtr($floatstruct)) ;AARRGGBB to float For $y = 0 To $Height - 1 $RowOffset = $y * $Width + 1 For $x = 0 To $Width - 1 $oldPixel = Dec(Hex(DllStructGetData($Pixels1, 1, $x + $RowOffset), 2)) / 255 DllStructSetData($floatstruct, 1, $oldPixel) ;write into float struct $oldPixel = DllStructGetData($dwordstruct, 1) ;read as dword (aka "pixel" AARRGGBB) DllStructSetData($Pixels1, 1, $oldPixel, $x + $RowOffset) ;store the float number as "pixel" AARRGGBB Next Next For $y = 0 To $Height - 1 $RowOffset = $y * $Width + 1 For $x = 0 To $Width - 1 $oldpixel = DllStructGetData($Pixels1, 1, $x + $RowOffset) DllStructSetData($dwordstruct, 1, $oldPixel) ;write into dwordstruct (place of floatstruct) $oldPixel = DllStructGetData($floatstruct, 1) ;read float $newpixel = ($oldpixel <= 0.5) ? 0:1 DllStructSetData($Pixels1, 1, "0xFF" & Hex($newpixel * 255, 2) & Hex($newpixel * 255, 2) & Hex($newpixel * 255, 2), $x + $RowOffset) $quant_error = $oldPixel - $newpixel ;-------Floyd-Steinberg For $Loop = 0 To 3 $pixel = DllStructGetData($Pixels1, 1, ($x + $Floyd[$Loop+4]) + ($y + $Floyd[$Loop+8]) * $Width + 1);get pixel integer/DWORD AARRGGBB DllStructSetData($dwordstruct, 1, $pixel) ;set into DWORD struct $col = DllStructGetData($floatstruct, 1) ;read float from DWORD $float = $col + ($Floyd[$Loop] / 16 * $quant_error) ;calculate with float DllStructSetData($floatstruct, 1, $float) ;write into float struct $pixel = DllStructGetData($dwordstruct, 1) ;get dword from float and DllStructSetData($Pixels1, 1, $pixel, ($x + $Floyd[$Loop+4]) + ($y + $Floyd[$Loop+8]) * $Width + 1) ;write the "float" as a "pixel" Next Next Next _GDIPlus_BitmapUnlockBits($Image, $Bitmap1) _GDIPlus_GraphicsDrawImageRect($Graphics, $Image, 0, 0, $Width, $Height) While GUIGetMsg <> -3 Sleep(10) WEnd Func _exit() Exit EndFunc- 19 replies
-
- dithering
- floyd-steinberg
-
(and 1 more)
Tagged with:
-
Werty reacted to a post in a topic: Trouble with Floyd-Steinberg dithering
-
Trouble with Floyd-Steinberg dithering
Werty replied to Werty's topic in AutoIt General Help and Support
Beautiful, exactly what I need, much appreciated, very close to the PaintShopPro results I've been using. I kinda figured it had something to do with floating point, reading around many websites, but from there to actually fixing it... 😛 Now to figure out how to speed it up, I usually use c-dll's though rather simple ones using TCC, but maybe it'll work out, Thanks again, much appreciated.- 19 replies
-
- dithering
- floyd-steinberg
-
(and 1 more)
Tagged with:
-
ioa747 reacted to a post in a topic: Trouble with Floyd-Steinberg dithering
-
Trouble with Floyd-Steinberg dithering
Werty replied to Werty's topic in AutoIt General Help and Support
Thanks but sorry to say that it's actually much worse than mine, there are too many large areas that are blank, i need it evenly distributed as in the sample images i posted. I've been trying for days now, but not giving up, maybe I should try separating it all into funcs as in your code, though as i wrote earlier, I will only be feeding it 8bit grayscale so no need for the 24bit support your code has. I'll examine your script more thoroughly, I already tried clamping but will again, and look into the error distribution thingie. But please, anyone. try adding a consolewrite below the iNewColor and you will see why, copilots code doesnt work, or atleast is faulty. ; Set the new pixel color $iNewColor = _ColorSetRGB($aColor) consolewrite(Hex($iNewcolor, 8) & @crlf) _GDIPlus_BitmapSetPixel($hBitmap, $x, $y, $iNewColor) EndFunc ;==>_DistributeError- 19 replies
-
- dithering
- floyd-steinberg
-
(and 1 more)
Tagged with:
-
Trouble with Floyd-Steinberg dithering
Werty replied to Werty's topic in AutoIt General Help and Support
I should ofcourse have posted some comparison images, it's supposed to look something like this (from paintshop pro)... And another example, first pic is the original, second made in paintshop pro, third my result, easy to spot the artifacts mine has.- 19 replies
-
- dithering
- floyd-steinberg
-
(and 1 more)
Tagged with:
-
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)
- 19 replies
-
- dithering
- floyd-steinberg
-
(and 1 more)
Tagged with:
-
Umm, could you post one of the pics, sounds alot like a game.
-
Werty reacted to a post in a topic: AutoIt Wrapper For RapidOCR
-
Werty reacted to a post in a topic: Cairo 2D graphics library build 2024-04-02 alpha
-
Event based new message box opening detection
Werty replied to VAN0's topic in AutoIt General Help and Support
That's an interesting monitor setup you have, looking at "Position: 4236, -830" you must have a multimonitor setup where the primary monitor is bottom monitor and the secondary on top, and you either have a huge 49" monitor with a smaller on top or a triple/quad monitor setup. That might interfere with something, have you tried with notepad starting at the same position/monitor as VCarve and see if that still work?. -
I doubt this will work with hidden taskbar.
-
AutoIt help file for dark environment
Werty replied to argumentum's topic in AutoIt Projects and Collaboration