It is currently Wed May 01, 2024 4:15 pm


All times are UTC - 5 hours [ DST ]



Post new topic Reply to topic  [ 39 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: Multi Threshold G'MIC plugin AKA "Pre Obama Posterize" Script.
PostPosted: Wed Aug 24, 2016 12:18 pm  (#1) 
Offline
Script Coder
User avatar

Joined: May 07, 2014
Posts: 3975
Location: Canada
This is a G'MIC plugin script.
In Linux, look for a file called .gmic in your $HOME/ folder
On Windows, it's a filed called user.gmic in your %APPDATA%/ (on mine it's C:\Users\Tin Tran\AppData\Roaming\user.gmic
If it's not there create it.
If it's there paste this code in there at the appropriate place, i hope you're able to tell where the appropriate place is (I am guessing just end of file) I don't know because I previously don't have that file.
#@gmic
#@gimp <b>.{development filters}</b>

#@gimp Multi Thresholds : multi_threshold, multi_threshold
#@gimp : Threshold_1 = int(50,1,256)
#@gimp : Threshold_2 = int(100,1,256)
#@gimp : Threshold_3 = int(150,1,256)
#@gimp : Threshold_4 = int(200,1,256)
multi_threshold :
   --luminance[0] -threshold[-1] 1  -normalize[-1] 0,255 -to_colormode[-1] 4
   --luminance[0] -threshold[-1] $1 -normalize[-1] 0,255 -to_colormode[-1] 4
   --blend[-1,-2] difference -replace_color[-1] 0,0,255,255,255,255,9,0,1,255
   
   --luminance[0] -threshold[-1] {$1} -normalize[-1] 0,255 -to_colormode[-1] 4
   --luminance[0] -threshold[-1] {$2} -normalize[-1] 0,255 -to_colormode[-1] 4
   --blend[-1,-2] difference -replace_color[-1] 0,0,255,255,255,255,175,42,27,255
   
   --luminance[0] -threshold[-1] {$2} -normalize[-1] 0,255 -to_colormode[-1] 4
   --luminance[0] -threshold[-1] {$3} -normalize[-1] 0,255 -to_colormode[-1] 4
   --blend[-1,-2] difference -replace_color[-1] 0,0,255,255,255,255,101,101,101,255
   
   --luminance[0] -threshold[-1] {$3} -normalize[-1] 0,255 -to_colormode[-1] 4
   --luminance[0] -threshold[-1] {$4} -normalize[-1] 0,255 -to_colormode[-1] 4
   --blend[-1,-2] difference -replace_color[-1] 0,0,255,255,255,255,174,165,131,255
   
   --luminance[0] -threshold[-1] {$4} -normalize[-1] 0,255 -to_colormode[-1] 4
   --luminance[0] -threshold[-1] 256 -normalize[-1] 0,255 -to_colormode[-1] 4
   --blend[-1,-2] difference -replace_color[-1] 0,0,255,255,255,255,247,228,160,255
   
   -remove[-2,-3,-5,-6,-8,-9,-11,-12,-14,-15]
   
   --blend[-1,-2,-3,-4,-5] add
   
   -remove[-2,-3,-4,-5,-6]
   
   -move[-1] 0
   
   -remove[1]
   
#@gimp _

Alternately if you do not yet have the .gmic file or user.gmic file already just use this file.
Attachment:
user.gmic.zip [479 Bytes]
Downloaded 228 times


And then you'll have an available filter in G'MIC that looks like this.
Image
You can control these 4 thresholds on the fly and preview the result (a little slow but i am just happy it works).
Then after applying, you can run the Obama Posterize scheme script
And the result will reflect the manual multi thresholds that you used.

As an example here this result i have it reflects the thresholds that I used above.
Image

Warning: Threshold1 < Threshold2 < Threshold3 < Threshold4. Thresholds must be incrementally different. If a lower numbered threshold is higher than a higher numbered threshold, it'll poop out and give white areas. You've been warned. :hehe

_________________
TinT


Last edited by trandoductin on Wed Aug 24, 2016 10:24 pm, edited 1 time in total.

Share on Facebook Share on Twitter Share on Orkut Share on Digg Share on MySpace Share on Delicious Share on Technorati
Top
 Post subject: Re: Multi Threshold G'MIC plugin AKA "Pre Obama Posterize" Script.
PostPosted: Wed Aug 24, 2016 1:05 pm  (#2) 
Offline
GimpChat Member

Joined: Sep 24, 2012
Posts: 275
Location: Scotland
G'MIC part is working fine, pretty sure it took a lot longer for me to get something useful out of G'MIC. Nicely done :yup


Top
 Post subject: Re: Multi Threshold G'MIC plugin AKA "Pre Obama Posterize" Script.
PostPosted: Wed Aug 24, 2016 1:15 pm  (#3) 
Offline
Script Coder
User avatar

Joined: May 07, 2014
Posts: 3975
Location: Canada
heheeh I don't think it's possible to take longer. I already milked all the hours out of the day hunting around for what i needed.
my goal was to make it work no matter how slow. :hehe

_________________
TinT


Top
 Post subject: Re: Multi Threshold G'MIC plugin AKA "Pre Obama Posterize" Script.
PostPosted: Wed Aug 24, 2016 5:33 pm  (#4) 
Offline
GimpChat Member
User avatar

Joined: Jul 06, 2013
Posts: 2606
Location: California
This seems like a nice filter, but the folder doesn't come up for me in C:/Users/Mackenzie.

It only comes up in the search but the folder itself isn't visible. I have windows 7 64Bit


Top
 Post subject: Re: Multi Threshold G'MIC plugin AKA "Pre Obama Posterize" Script.
PostPosted: Wed Aug 24, 2016 6:20 pm  (#5) 
Offline
Script Coder
User avatar

Joined: May 07, 2014
Posts: 3975
Location: Canada
The AppData folder is defaulted as hidden folder.
Trying clicking on View when you're viewing your user's folder, and then tick the Hidden Items or something similar and it'll appear.
Image

_________________
TinT


Top
 Post subject: Re: Multi Threshold G'MIC plugin AKA "Pre Obama Posterize" Script.
PostPosted: Wed Aug 24, 2016 7:00 pm  (#6) 
Offline
GimpChat Member
User avatar

Joined: Jul 06, 2013
Posts: 2606
Location: California
trandoductin wrote:
The AppData folder is defaulted as hidden folder.
Trying clicking on View when you're viewing your user's folder, and then tick the Hidden Items or something similar and it'll appear.
[ Image ]


I don't see anything like what your image showed. However, when I click properties, I see this:

Image


Last edited by mackenzieh on Wed Aug 24, 2016 7:21 pm, edited 3 times in total.

Top
 Post subject: Re: Multi Threshold G'MIC plugin AKA "Pre Obama Posterize" Script.
PostPosted: Wed Aug 24, 2016 7:13 pm  (#7) 
Offline
Script Coder
User avatar

Joined: May 07, 2014
Posts: 3975
Location: Canada
mackenzieh wrote:
trandoductin wrote:
The AppData folder is defaulted as hidden folder.
Trying clicking on View when you're viewing your user's folder, and then tick the Hidden Items or something similar and it'll appear.
[ Image ]


I don't see anything like what your image showed.

https://www.google.ca/search?q=how+to+show+hidden+files+on+windows+7&ie=utf-8&oe=utf-8&gws_rd=cr&ei=ETi-V8v9GoLhjAPcy4aoCA

_________________
TinT


Top
 Post subject: Re: Multi Threshold G'MIC plugin AKA "Pre Obama Posterize" Script.
PostPosted: Wed Aug 24, 2016 7:22 pm  (#8) 
Offline
GimpChat Member
User avatar

Joined: Jul 06, 2013
Posts: 2606
Location: California
trandoductin wrote:
mackenzieh wrote:
trandoductin wrote:
The AppData folder is defaulted as hidden folder.
Trying clicking on View when you're viewing your user's folder, and then tick the Hidden Items or something similar and it'll appear.
[ Image ]


I don't see anything like what your image showed.

https://www.google.ca/search?q=how+to+show+hidden+files+on+windows+7&ie=utf-8&oe=utf-8&gws_rd=cr&ei=ETi-V8v9GoLhjAPcy4aoCA


I edited my previous post.


Top
 Post subject: Re: Multi Threshold G'MIC plugin AKA "Pre Obama Posterize" Script.
PostPosted: Wed Aug 24, 2016 7:27 pm  (#9) 
Offline
Script Coder
User avatar

Joined: May 07, 2014
Posts: 3975
Location: Canada
go to the link i posted it tells you how to do it on Windows 7 there are minor differences on different windows.

_________________
TinT


Top
 Post subject: Re: Multi Threshold G'MIC plugin AKA "Pre Obama Posterize" Script.
PostPosted: Wed Aug 24, 2016 7:37 pm  (#10) 
Offline
GimpChat Member
User avatar

Joined: Jul 06, 2013
Posts: 2606
Location: California
trandoductin wrote:
go to the link i posted it tells you how to do it on Windows 7 there are minor differences on different windows.


I've changed my mind. I'll wait to see if the new version of GMIC gets this plugin installed.


Top
 Post subject: Re: Multi Threshold G'MIC plugin AKA "Pre Obama Posterize" Script.
PostPosted: Wed Aug 24, 2016 8:41 pm  (#11) 
Offline
Script Coder
User avatar

Joined: May 07, 2014
Posts: 3975
Location: Canada
i don't know what the process is for it to get into the next build.

_________________
TinT


Top
 Post subject: Re: Multi Threshold G'MIC plugin AKA "Pre Obama Posterize" Script.
PostPosted: Wed Aug 24, 2016 9:11 pm  (#12) 
Offline
GimpChat Member
User avatar

Joined: Jul 06, 2013
Posts: 2606
Location: California
trandoductin wrote:
i don't know what the process is for it to get into the next build.


Me neither but I'm okay with waiting to see if it gets into the next build.


Top
 Post subject: Re: Multi Threshold G'MIC plugin AKA "Pre Obama Posterize" Script.
PostPosted: Thu Aug 25, 2016 1:11 am  (#13) 
Offline
GimpChat Member
User avatar

Joined: Jan 13, 2011
Posts: 2251
Location: Poland
It works great in Vista 32 Bit (for GIMP 2.8.18 i 2.9.5)
I changed a location in the menu GMIC.
Thanks Tin. :jumpclap


Attachments:
MultiThresholds.png
MultiThresholds.png [ 38.62 KiB | Viewed 1398 times ]

_________________
Image

Slava
Ukraini!
Top
 Post subject: Re: Multi Threshold G'MIC plugin AKA "Pre Obama Posterize" Script.
PostPosted: Thu Aug 25, 2016 10:56 am  (#14) 
Offline
Script Coder
User avatar

Joined: May 07, 2014
Posts: 3975
Location: Canada
MareroQ, do you know what the process is (in order to get it into the next G'Mic build)?

_________________
TinT


Top
 Post subject: Re: Multi Threshold G'MIC plugin AKA "Pre Obama Posterize" Script.
PostPosted: Thu Aug 25, 2016 11:07 am  (#15) 
Offline
GimpChat Member
User avatar

Joined: May 16, 2010
Posts: 14709
Location: USA
Image

I just opened notepad ++ and created the file and saved as "user.gmic" in the roaming folder in windows 10. :bigthup
Thanks, this works nicely for preview before executing the script.

Image

_________________
Image
Edmund Burke nailed it when he said, "The only thing necessary for the triumph of evil is for good men to do nothing."


Top
 Post subject: Re: Multi Threshold G'MIC plugin AKA "Pre Obama Posterize" Script.
PostPosted: Thu Aug 25, 2016 11:12 am  (#16) 
Offline
Script Coder
User avatar

Joined: May 07, 2014
Posts: 3975
Location: Canada
but it is still slow...at least i think so
for each threshold color i had to blend 2 layers using subtract mode so 10 layers + 5 result layers, then blend all 5 layers using addition at the end.
If i only knew what blending mode to use to get normal like what how Gimp treats layers I think it'd be much faster.

_________________
TinT


Top
 Post subject: Re: Multi Threshold G'MIC plugin AKA "Pre Obama Posterize" Script.
PostPosted: Thu Aug 25, 2016 11:26 am  (#17) 
Offline
GimpChat Member

Joined: Sep 24, 2012
Posts: 275
Location: Scotland
Hopefully when David's back he will add a new gmic community file for you (so it appears on filter list after refresh).

Perhaps the blending mode you're after is "blend alpha" ?

I may have time at the weekend to look more closely and help speed things up...


Top
 Post subject: Re: Multi Threshold G'MIC plugin AKA "Pre Obama Posterize" Script.
PostPosted: Thu Aug 25, 2016 1:01 pm  (#18) 
Offline
Script Coder
User avatar

Joined: May 07, 2014
Posts: 3975
Location: Canada
I have looked that this page https://sourceforge.net/p/gmic/wiki/Blending%20modes/
And none of the modes does a normal gimp layer over top of layer result.

Correction: Alpha seems like what i want to do according to the above page...but when i try it it doesn't seem to want to work i keep getting a whole layer filled with one color.

_________________
TinT


Top
 Post subject: Re: Multi Threshold G'MIC plugin AKA "Pre Obama Posterize" Script.
PostPosted: Thu Aug 25, 2016 2:13 pm  (#19) 
Offline
GimpChat Member

Joined: Sep 24, 2012
Posts: 275
Location: Scotland
OK I couldn't resist :oops:

Here's another way of doing it:

#@gimp Multi Thresholds : multi_threshold, multi_threshold
#@gimp : Threshold_1 = int(50,0,255)
#@gimp : Threshold_2 = int(100,0,255)
#@gimp : Threshold_3 = int(150,0,255)
#@gimp : Threshold_4 = int(200,0,255)
multi_threshold :
  -repeat $! -l[$>]
    -split_opacity --rgb2ycbcr[0] -channels. 0 -fc[0] 9,0,1
    --fc[0] 175,42,27 --ge[-2] $1 -j[0] [-2],0,0,0,0,1,[-1] -rm[-2,-1]
    --fc[0] 101,101,101 --ge[-2] $2 -j[0] [-2],0,0,0,0,1,[-1] -rm[-2,-1]
    --fc[0] 174,165,131 --ge[-2] $3 -j[0] [-2],0,0,0,0,1,[-1] -rm[-2,-1]
    --fc[0] 247,228,160 --ge[-2] $4 -j[0] [-2],0,0,0,0,1,[-1] -rm[-2,-1]
    -rm. -a c
  -endl -done


There are even shorter ways but then it becomes hard to read.

Some explanation:
--rgb2ycbr -channels. 0 = another way of getting luminance
--fc[0] r,g,b = take a copy of image [0] and fill with rgb color
--ge[-2] x = create a new image from luminance, any value greater than or equal to x will be 1
-j[0] [-2],0,0,0,0,1,[-1] = draw image [-2] onto image [0] using [-1] as a mask


Top
 Post subject: Re: Multi Threshold G'MIC plugin AKA "Pre Obama Posterize" Script.
PostPosted: Thu Aug 25, 2016 2:18 pm  (#20) 
Offline
Script Coder
User avatar

Joined: May 07, 2014
Posts: 3975
Location: Canada
I have no idea how you do it..but this version is awesome it doesn't bug out when threshold is out of whack either and seems
super fast.
Great...now how do we get this into the next build?

_________________
TinT


Top
Post new topic Reply to topic  [ 39 posts ]  Go to page 1, 2  Next

All times are UTC - 5 hours [ DST ]


   Similar Topics   Replies 
No new posts Attachment(s) Seeking Help with First Multi-File Batch Script

9

No new posts Attachment(s) Is there a Blinds script/plugin for gimp 2.10.10

16

No new posts Looking for the Text Stamp Plugin/Script

4

No new posts Plugin or Script to bend/curve text

17

No new posts Script passes a 0 to the Displace plugin, and apparently it's an issue

0



* Login  



Powered by phpBB3 © phpBB Group