Excellent result!AAT wrote: I have another version of the converted picture![]()
That's just upsetting size of the program as a result.
Excellent result!AAT wrote: I have another version of the converted picture![]()
Code: Select all
UseJPEGImageEncoder()
UseJPEGImageDecoder()
Procedure plot_(x, y, gray)
If Red(gray)<70
Plot(x, y, RGB(gray, gray, gray))
EndIf
EndProcedure
Value = 0 ; Or 1
Threshold =270 ;The threshold of sensitivity
Pattern$ = "Image |*.jpg;*.bmp"
Pattern = 0
File$ = OpenFileRequester("Image JPG,BMP", StandardFile$, Pattern$, Pattern)
If File$
If LoadImage(0,File$)
Dim Colors(ImageWidth(0),ImageHeight(0))
StartDrawing( ImageOutput(0))
For x = 0 To ImageWidth(0) -1
For y = 0 To ImageHeight(0)-1
Colors(x,y) = Point(x, y)
Next
Next
StopDrawing()
CopyImage(0, 1)
EndIf
StartDrawing( ImageOutput(1))
For x = 1 To ImageWidth(0) - 2
For y = 1 To ImageHeight(0) - 2
temp = Colors(x,y)
Orig_blue = Blue(temp)
Orig_green = Green(temp)
Orig_red = Red(temp)
Diff = 0
For xx = x - 1 To x + 1
For yy = y - 1 To y + 1
If (xx <> x) Or (yy <> y)
temp = Colors(xx,yy)
Other_blue = Blue(temp)
Other_green = Green(temp)
Other_red = Red(temp)
temp = (Orig_red - Other_red) * (Orig_red - Other_red) + (Orig_blue - Other_blue)*(Orig_blue - Other_blue)+(Orig_green - Other_green) * (Orig_green - Other_green)
Diff = Diff +Sqr(temp)
EndIf
Next yy
Next xx
If Value = 0
Diff = 255 - Diff
If Diff < 0: Diff = 0: EndIf
If Diff > 255: Diff = 255:EndIf
Plot_ (x, y, RGB(Diff, Diff, Diff))
Else
If Diff > Threshold
Diff = 255 - (Diff - Threshold)
If Diff < 0 : Diff = 0:EndIf
If Diff > 255 : Diff = 255:EndIf
Plot_ (x, y, RGB(Diff, Diff, Diff))
Else
Plot_ (x, y, RGB(255, 255, 255))
EndIf
EndIf
Next y
Next x
StopDrawing()
If SaveImage(1,GetTemporaryDirectory() + "charcoal.jpg",#PB_ImagePlugin_JPEG)
RunProgram(GetTemporaryDirectory() + "charcoal.jpg")
EndIf
Else
MessageRequester("Information", "The requester was canceled.", 0)
EndIf
Code: Select all
;imitation pastel - pencil drawing
; kvitaliy 2016 г.
UseJPEGImageEncoder()
UseJPEGImageDecoder()
w=3 ; The thickness can be changed (1-5)
Pattern$ = "Image |*.jpg;*.bmp"
Pattern = 0
File$ = OpenFileRequester("Image JPG,BMP", StandardFile$, Pattern$, Pattern)
If File$
If LoadImage(0,File$)
conversionTime = ElapsedMilliseconds() ; Start Timer
Dim Colors(ImageWidth(0),ImageHeight(0))
StartDrawing( ImageOutput(0))
For x = 0 To ImageWidth(0) -1
For y = 0 To ImageHeight(0)-1
Colors(x,y) = Point(x, y)
Next
Next
StopDrawing()
CopyImage(0, 1)
EndIf
StartDrawing( ImageOutput(1))
For x = 1 To ImageWidth(0) - 1
For y = w To ImageHeight(0) - 1
temp1 = Colors(x,y-w)
R1=Red(temp1):G1=Green(temp1):B1=Blue(temp1)
temp3 = Colors(x,y)
R3=Red(temp3):G3=Green(temp3):B3=Blue(temp3)
R = Sqr((R1 - R3)*(R1 - R3)+(R3 - R1)*(R3 - R1))
G = Sqr((G1 - G3)*(G1 - G3)+(G3 - G1)*(G3 - G1))
B = Sqr((B1 - B3)*(B1 - B3)+(B3 - B1)*(B3 - B1))
If R>255:R=255:EndIf
If G>255:G=255:EndIf
If B>255:B=255:EndIf
Plot (x , y, RGB(R,G,B) ! $FFFFFF) ;pastel drawing
;Plot (x , y, RGB(R,G,B)) ; Or neon glow
Next y
Next x
StopDrawing()
conversionTime = ElapsedMilliseconds() - conversionTime ; Stop Timer
MessageRequester("Conversion time", Str(conversionTime)+" mS.",0)
If SaveImage(1,GetTemporaryDirectory() + "charcoal.jpg",#PB_ImagePlugin_JPEG)
RunProgram(GetTemporaryDirectory() + "charcoal.jpg")
EndIf
Else
MessageRequester("Information", "The requester was canceled.", 0)
EndIf
Very nice !BasicallyPure wrote: See my previous post for the code.