why does rounding rgb's on a picture (yep, that's what i'm doing!) make it look purple and grey? (even rounding to the nearest 1 using your function!, shouldnt affect it should it?)
Here's the code I'm using:
Graphics 1280, 1024, 32, 1
Global imageid, image, bias
Global r, g, b, av, n, m
imageid=Input$("Image name and extension : ")
bias=Input$("To what nearest number should the rgb's be rounded to?")
;bias = Float bias
;bias = bias/(bias*10)
If bias=0 Then bias=10
image=LoadImage ("image.jpg")
Cls
DrawImage image, 0, 0
WaitKey()
For n=0 To ImageWidth (image)
For m=0 To ImageHeight (image)
GetColor n, m
r=ColorRed()
g=ColorGreen()
b=ColorRed()
r=(round( r, 15))
g=(round( g, 15))
b=(round( b, 15))
;r=(round( r, 255))
;g=(round( g, 255))
;b=(round( b, 255))
;av = (r + g + b) / 3
;r = av : g = av : b = av
Color r, g, b
;Plot 1280, 0
Rect 1000, 1000, 2, 2, 1
If ImageHeight(image) < 500 Then
writepixelsfast
Else
writepixels
EndIf
If KeyHit(1) Then Goto endl
Next
Next
Repeat
Color 0, 0, 0
Rect 1000, 1000, 280, 24, 1
GetColor MouseX(), MouseY()
Text 1000, 1000, "mouse location rgb = " + ColorRed() + " " + ColorGreen() + " " + ColorBlue()
Delay 15
Until KeyHit(1)
.endl
End
Function Round( Number , N )
If ( Number Mod N ) >= ( N *.5 )
Number = ( Ceil( Number / N ) + 1 ) * N
Else
Number = Floor( Number / N ) * N
EndIf
Return Number
End Function
Function writepixelsfast()
If ImageHeight(image)*2 > 1024 Then
WritePixelFast n+ImageWidth(image), m, ReadPixelFast(1000, 1000)
Else If ImageWidth*2 > 1280 Then
WritePixelFast n, m+ImageHeight (image), ReadPixelFast(1000, 1000)
EndIf
End Function
Function writepixels()
If ImageHeight(image)*2 > 1024 Then
WritePixel n+ImageWidth(image), m, ReadPixel(1000, 1000)
Else If ImageWidth*2 > 1280 Then
WritePixel n, m+ImageHeight (image), ReadPixel(1000, 1000)
EndIf
End Function
|