Jump to content

Reptorian's G'MIC Code Workshop


Reptillian

Recommended Posts

35 minutes ago, lifeday said:

 

Hello @Reptillian,

 

The Embass Relief does not work in color in the latest gmic for gimp version.
Here on paint.net it works great!

 

Since I do not use GIMP as my main program at all nor installed G'MIC there, can you please file a issue in here - https://github.com/Reptorian1125/gmic-community

 

Insert details like what does it do when you tried the relief mode? What do you expect? Error message? You can also post a log.

Edited by Reptillian

G'MIC Filter Developer

Link to comment
Share on other sites

On 3/23/2019 at 11:21 AM, lifeday said:

 

Hello @Reptillian,

 

The Embass Relief does not work in color in the latest gmic for gimp version.
Here on paint.net it works great!

 

There, I believe I should have fixed it. Here, meanwhile, you could do this to verify for me. First update gmic, then do these steps.

 

1) Type in "%appdata%/gmic" in Windows Explorer

2) If you have something like Kate or notepad++, right-click, and click edit updatexxxx.gmic where xxxx represent latest .gmic version.

3) Search "#@gui Emboss-Relief"

4) Replace the existing code by highlighting it, and then copy and paste this

#@gui Emboss-Relief : fx_emboss_relief, fx_emboss_relief_preview(0)
#@gui : sep = separator(), Enable Extreme Emboss or Relief? = bool(0), sep = separator()
#@gui : Angle = float(0,0,360)
#@gui : Depth (%) = float(100,0,500)
#@gui : Depth (%) = float(500,500,5000)
#@gui : Smoothness = float(0,0,10)
#@gui : Invert Embossing? = bool(0)
#@gui : Preserve Alpha? = bool(1)
#@gui : sep = separator(), note = note("Relief Section")
#@gui : Apply Relief? = bool(1)
#@gui : Blending Opacity (%) = float(100,0,100)
#@gui : sep = separator(), Preview Type = choice("Full","Forward Horizontal","Forward Vertical","Backward Horizontal","Backward Vertical","Duplicate Top","Duplicate Left","Duplicate Bottom","Duplicate Right","Duplicate Horizontal","Duplicate Vertical","Checkered","Checkered Inverse"), Preview split = point(50,50,0,0,200,200,200,0,10,0)
#@gui : sep = separator(), note = note("<small>Author: Reptorian.      Latest Update: <i>2019/3/19</i>.</small>")
fx_emboss_relief : repeat $! l[$>] split_opacity if $8 +em[0] {$6?$2+180:$2},{$1?$4/100:$3/100},$5 blend[^1] grainmerge,{$9/100} else em[0] {$6?$2+180:$2},{$1?$4/100:$3/100},$5 fi if $7 a c else k[0] fi endl done
fx_emboss_relief_preview :
gui_split_preview "fx_emboss_relief $*",${-3--1}
u "{$1}"\
"{$2}"\
"{$3}_"{$1==1?0:2}\
"{$4}_"{$1==1?2:0}\
"{$5}"\
"{$6}"\
"{$7}"\
"{$8}"\
"{$9}_"{$8==1?2:1}\
"{$10}{$11,$12}"

 

Edited by Reptillian

G'MIC Filter Developer

Link to comment
Share on other sites

 @Reptillian

 

Reptillian answers: Since I do not use GIMP as my main program at all nor installed G'MIC there, . . . . .

 

1.

Sorry, I didn't realize you weren't on Gimp. I go here at Paint. net and also at Gimp in Gmic - Testing. And there I tried your filters - they look great in processing.  Well, short and sweet, I thought it would interest you that in Gimp "Emboss" in the latest version is not executed in color. It appears "time out" and it is time out.  I didn't mean to annoy you! I will address my text to Github. Maybe it will help. If not, it's OK too, because Emboss runs great on my main portal Paint.Net. 

 

 

Reptillian wrote: There, I believe I should have fixed it. Here, meanwhile, you could do this to verify for me. First update gmic, then do these steps.

 

2. 

Thank you for your execution. Sorry, I can't do that. I am a pure user and understand instructions when they show me exactly how to proceed. 
I tried yesterday and the day before yesterday to add the latest version of Gmic to Gimp, it didn't work. I watched on several videos about Gmic installation and only my daughter gave me the final tip. So  -  on Gimp is the newest Gmic version. 
I have to pass when it comes to changing it. I'm sorry, I would have liked to do it, but it just comes out chaos with me, so I keep my hands off it.

 

Have a nice day!

Link to comment
Share on other sites

@Seerose  wrote: 

I Like it very well.  Thank you for sharing your result!  

Love hugs, and beautiful weekend. 💐

 

Dear Seerose,

 

Thank you very much for your appreciation. I was very happy to  here  from you. 
I wish you a wonderful Sunday evening and tomorrow a good start into the new week.

 

Greetings from Hamburg

Link to comment
Share on other sites

@lifeday Another update! Samj at discuss.pixls forum found the solution. It's settled - https://discuss.pixls.us/t/reptorian-gmic-filters/9165/96?u=reptorian

 

The solution was to add 'to_a'. You don't need to file issue or verify that it works. All is fine and dandy now. The reason why I had to add 'to_a' is that GIMP has this weirdness where layers could have no alpha channel at all, and that's not the behavior of literally almost every other application that works with alpha channels. That's the downfall of G'MIC scripting unfortunately, though its universality makes it worth pursuing in the end.

Edited by Reptillian
  • Upvote 1

G'MIC Filter Developer

Link to comment
Share on other sites

@Reptillian

 

 

Thank you very much for the news - but the problem has not got better but much worse. About Gimp I will not post the result here, it is worse than what I get here on paint.net as a result. I put a try from yesterday in paint.net and another try from today. Judge for yourself what is more beautiful. My judgement stands! ;)


Emboss Relief can now be found under Faves, which is very practical. 

 

(Left Embass Relief yesterday, right Embass Relief now.


greetings

 

flower_doppeltbild.jpg

Link to comment
Share on other sites

Unexpected news. The main maintainer of G'MIC has added new commands which means there'll be even more updates on the upcoming new updated color modulo texture. He made rgb2ryb/ryb2rgb, and he also added a new feature with apply_channel which is that you can apply command to ryb model.

 

Color modulo texture will have RYB - Additive mode ; RYB - Subtractive Mode ; RYB - Painting Pigment Based Mode.

 

The last one is based on my own command translating pigment based codes.

 

What this means is that you'll have the option to use Yellow instead of green. The first 2 don't lose any colors. The last one loses blue-green solely because of its property.


Sample Image of Color Modulo Texture with RYB8-P

 

image.png.874c5642ca1b657653458618e6396102.png

 

Beautiful, huh?

Edited by Reptillian
  • Like 2

G'MIC Filter Developer

Link to comment
Share on other sites

That is pretty neat @Reptillian!  I couldn't tell it was a car until I sat back in my chair.

 

Lots of little images in there...I see heads, gradients and well, just lots of stuff!  :lol:

 

Can't wait till it's finished so I can try it out.  :)

Link to comment
Share on other sites

All I need to do is to find out how to import pictures specifying only the directory on the GUI filter. I don't know how to do that yet. I changed the algorithm, and it is vastly improved in accuracy.

8156d0cdc16ecbf33993280ab3ba53bb8b13a2b6

 

 

Note that there's more random pictures, but also more clarity. You can also specify dithering factor. Also, note that the picture is transparent. Yes, it supports alpha images too. For target, and reference pictures.

Edited by Reptillian
  • Like 1

G'MIC Filter Developer

Link to comment
Share on other sites

Submitted pull request to G'MIC Community so that mosaic filter can be tested soon. Also, aspect ratio cropping is another new filter of mine, and the command was used in mosaic filter.

 

Also, there's a bug with mosaic filter. I don't know why the end result shrinks. But, it isn't coming from my end since it works fine without folder input option assuming 3 or more images are used using 'All' input layers inside GIMP, and Krita. So, Paint.NET users will need to hold out a bit for a working version. You may have to manually resize the image. There's still the option of copying the mosaic code which I will copy and paste into here if there's any filter developers interested into such a filter.

 

#@cli rep_mosaic_gen: autocrop_median_bool[0=Do not autocrop||1=Autocrop by median],aspect_ratio_linear_interpolation[0=Nearest Neighborhood||1=Linear],0>=dithering>=1,image_scale_interpolation,0>=tile_width,0>=tile_height
#@cli: Generates mosaic using multiple pictures using indexing methodology, and uses average to determine the mapping based on colors. Tile_Width and Tile_Height cannot be both zero!
rep_mosaic_gen:
skip ${1=0},${2=1},${4=5},${6=0} #Set variable to number when no inputs#
if {$!<=2} v + error "You need to have at least 3 images to generate a mosaic!" fi #Condition for working mosaic filter#
fim_number={$!-1} #Total images number#
in_a={int($5)} #Width#
in_b={int($6)} #Height#
in_c={$in_a*$in_b} #Used to validate if one of those variable is 0#
v={$in_a+$in_b} #Used as a variable to compute mini-images size#
iw={w} #Image Width#
ih={h} #Image Height#
vw={$in_c==0?floor(w>h?$v:w/h*$v):$in_a} #If width or height is 0, then either the width or height is automatically calculated based on image ratio#
vh={$in_c==0?floor(h>w?$v:h/w*$v):$in_b} #If width or height is 0, then either the width or height is automatically calculated based on image ratio#
mini_width={ceil(w/$vw)} #Width for backend image used for indexing based on palettes of all reference images#
mini_height={ceil(h/$vh)} #Height for used for indexing based on palettes of all reference images#
full_width={$mini_width*$vw} #Scaled backend image used for finding areas where to place images#
full_height={$mini_height*$vh} #Scaled backend image used for finding areas where to place images#

to_a
if $1 autocrop[^0] {ic} fi #Automatically crop images. The median is cropped out.#
+rep_lbchstatfunc_to_pal[^0] ia #Converts images to use as mini-images into palettes of average color based on image#
rep_aspect_crop_2d[^0,{$!-1}] {$vw},{$vh},,$2 #Fit images into aspect ratio. Needed for making the filter working as expected.#
r[^0,{$!-1}] {$vw},{$vh},1,4,$4 #Resize all images into vw, and vh factor#
+r[0] {$mini_width},{$mini_height},1,4,$4 #Create backend image#
split_opacity. #Split the opacity of backend image#
index.. ...,$3,1 #Index with the palettes of average colors of images used as mini-images#
a[-1,-2] c #Append backend image color and alpha channels#
rv[0,{$!-1}] rm. #Replace original image with indexed image and remove original image.#
r[0] {$full_width},{$full_height},1,4,1 #Resize the new image width into the nearestwidthto vw#
r[0-{$fim_number}] {$iw},{$ih},1,4,0,2 #Resize the new image height into the nearest height image to vh#
pal_l. #Convert Palette to Layer#
r[^0-{$fim_number}] {$iw},{$ih},1,3,1 #Resize palette layers into original image size#
split_opacity[0-{$fim_number}] #Split opacity of tiled images and the replacement of the original image#
repeat {$fim_number} l[0,{$!-$fim_number+$>}] f. "i#0==i#1?255:0" to_gray. endl done #Change the palette layer into the alpha based on the similarity of the replacement to the original image and the palette layer#
repeat {$fim_number} l[{($>*2)+3},{$!-$fim_number+$>}] +blend multiply rv[0,2] rm. endl done #Multiply the palette target alpha image and the tiled image alpha#
rm[{$!-$fim_number}-{$!-1}] #Remove the layers that is used to calculating where the mini-images will go#
repeat {$fim_number} a[{$>+2},{$>+3}] c done #Append the tile image and resulting tile image alpha#
blend[^0-1] alpha #Flatten the appended tile images#
rv[0,2] rm. #Remove the backend color image with the color flattened image#
split_opacity[0] #Split Opacity of the flattened image#
blend[^0] multiply #Multiply the back image alpha by the tiled image alpha#
a c #Append the color and alpha channel#

Edited by Reptillian
Fixing notes

G'MIC Filter Developer

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...