Humility Posted August 22, 2015 Share Posted August 22, 2015 I want to post a request for a plug in that would be able to identify contiguous colors and their size then recolor them based on a set of paremeters. Like say I might ask the plug-in to find contiguous areas of black, with a 1% tolerance and recolor any of these contiguous black areas comprised of 20 or fewer pixels into white. This would be really useful to me and I would like to know where I would post a request for a plug in like this. Quote Link to comment Share on other sites More sharing options...
Ego Eram Reputo Posted August 23, 2015 Share Posted August 23, 2015 You should be able to do this manually using the magic wand 1. Set your primary color to the new shade you want to install. 2. Activate the magic wand & set the toolbar tolerance to 1% and selection mode to contiguous. 3. Make a selection on the target color. 4. Selection size in pixels is shown in the Status bar. If less than <whatever> number of pixels, hit the Backspace key. 5. Repeat 3 & 4 as required. As far as a plugin, you've just made your request. A nice person might come along and write a plugin for you. Quote ebook: Mastering Paint.NET | resources: Plugin Index | Stereogram Tut | proud supporter of Codelab plugins: EER's Plugin Pack | Planetoid | StickMan | WhichSymbol+ | Dr Scott's Markup Renderer | CSV Filetype | dwarf horde plugins: Plugin Browser | ShapeMaker Link to comment Share on other sites More sharing options...
TechnoRobbo Posted August 25, 2015 Share Posted August 25, 2015 This sounds like a variation on the classic fill algorithm - I'll post some code and a dll when I get home. Quote Go out there and be amazing. Have Fun, TRSome Pretty Pictures Some Cool Plugins Link to comment Share on other sites More sharing options...
Humility Posted August 25, 2015 Author Share Posted August 25, 2015 (edited) @ego Oh I guess my use of the word contiguous was misleading. If What you describes works, but I would have to repeat that thousands of times. I meant something that could do all the the spots that are 20 pixels or less, at once. And thanks techno. Edited August 25, 2015 by Humility Quote Link to comment Share on other sites More sharing options...
TechnoRobbo Posted August 25, 2015 Share Posted August 25, 2015 OK,here it is. I called it TR's Speck Fill. It's in the Effects ->Color Menu. http://forums.getpaint.net/index.php?/topic/32193-where-would-i-post-a-plug-in-request/?p=430363 Quote Go out there and be amazing. Have Fun, TRSome Pretty Pictures Some Cool Plugins Link to comment Share on other sites More sharing options...
TechnoRobbo Posted August 26, 2015 Share Posted August 26, 2015 I revised the code, I had one line missing Quote Go out there and be amazing. Have Fun, TRSome Pretty Pictures Some Cool Plugins Link to comment Share on other sites More sharing options...
TechnoRobbo Posted August 26, 2015 Share Posted August 26, 2015 One last revision Quote Go out there and be amazing. Have Fun, TRSome Pretty Pictures Some Cool Plugins Link to comment Share on other sites More sharing options...
Eli Posted August 26, 2015 Share Posted August 26, 2015 Hello TR, I am trying to findout what to do with it. Perhaps a speckle cleaner?... Anyway, I got this error when I make a selection and Run the effect: File: C:\Program Files\paint.net\Effects\TRsSpecks.dll Name: TRsSpecksEffect.TRsSpecksEffectPlugin Version: 1.0.5715.37941 Author: Copyright © TechnoRobbo Copyright: TR's Speck Fill selected pixels Website: http://www.getpaint.net/redirect/plugins.html Full error message: PaintDotNet.WorkerThreadException: Worker thread threw an exception ---> System.IndexOutOfRangeException: Index was outside the bounds of the array. at TRsSpecksEffect.TRsSpecksEffectPlugin.check(Surface s, Int32 x, Int32 y, ColorBgra f, Int32 var, Int32 stop, Int32 size, Int32[,]& track) at TRsSpecksEffect.TRsSpecksEffectPlugin.Render(Surface dst, Surface src, Rectangle rect2) at TRsSpecksEffect.TRsSpecksEffectPlugin.OnRender(Rectangle[] rois, Int32 startIndex, Int32 length) at PaintDotNet.Effects.Effect`1.Render(Rectangle[] renderRects, Int32 startIndex, Int32 length) in d:\src\pdn\paintdotnet\src\Effects\Effect`1.cs:line 54 at PaintDotNet.Effects.Effect`1.Render(EffectConfigToken parameters, RenderArgs dstArgs, RenderArgs srcArgs, Rectangle[] rois, Int32 startIndex, Int32 length) in d:\src\pdn\paintdotnet\src\Effects\Effect`1.cs:line 97 at PaintDotNet.Effects.BackgroundEffectRenderer.RenderWithClipMask(Effect effect, EffectConfigToken token, RenderArgs dstArgs, RenderArgs srcArgs, Rectangle[] rois, IRenderer`1 clipMaskRenderer) in d:\src\pdn\paintdotnet\src\PaintDotNet\Effects\BackgroundEffectRenderer.cs:line 161 at PaintDotNet.Effects.BackgroundEffectRenderer.RendererContext.RenderTile(EffectConfigToken token, Int32 tileIndex) in d:\src\pdn\paintdotnet\src\PaintDotNet\Effects\BackgroundEffectRenderer.cs:line 141 at PaintDotNet.Effects.BackgroundEffectRenderer.RendererContext.RenderNextTile(EffectConfigToken token) in d:\src\pdn\paintdotnet\src\PaintDotNet\Effects\BackgroundEffectRenderer.cs:line 134 at PaintDotNet.Effects.BackgroundEffectRenderer.ThreadFunction() in d:\src\pdn\paintdotnet\src\PaintDotNet\Effects\BackgroundEffectRenderer.cs:line 226 --- End of inner exception stack trace --- at PaintDotNet.Effects.BackgroundEffectRenderer.DrainExceptions() in d:\src\pdn\paintdotnet\src\PaintDotNet\Effects\BackgroundEffectRenderer.cs:line 431 at PaintDotNet.Effects.BackgroundEffectRenderer.Abort() in d:\src\pdn\paintdotnet\src\PaintDotNet\Effects\BackgroundEffectRenderer.cs:line 386 at PaintDotNet.Effects.BackgroundEffectRenderer.Start() in d:\src\pdn\paintdotnet\src\PaintDotNet\Effects\BackgroundEffectRenderer.cs:line 332 at PaintDotNet.Menus.EffectMenuBase.<>c__DisplayClass31.<>c__DisplayClass35.<RunEffectImpl>b__25() in d:\src\pdn\paintdotnet\src\PaintDotNet\Menus\EffectMenuBase.cs:line 1003 Quote Link to comment Share on other sites More sharing options...
TechnoRobbo Posted August 26, 2015 Share Posted August 26, 2015 it doesn't use selections - not for his purpose code not quite ready yet Quote Go out there and be amazing. Have Fun, TRSome Pretty Pictures Some Cool Plugins Link to comment Share on other sites More sharing options...
Humility Posted August 26, 2015 Author Share Posted August 26, 2015 (edited) There are two things I want to do with it. Yes as a speckle cleaner as my needs are mostly mechanical not artistic. But on the artistic front it should help with making the resulting colors from noise more appeasing. But its not working. The size slider is having no apparent effect. Here let me give some images to help show what I mean. Though please don't laugh at how bad they are. This is the base image. http://i268.photobucket.com/albums/jj38/Humility1/The%20Unvieled%20Skirmishers.jpg Here is the image with the default settings of the speck tool. Notice is has very little effect. but it effects everything. Reducing a little bit on both the small black specks and the primary lines. http://i268.photobucket.com/albums/jj38/Humility1/The%20Unvieled%20Skirmishers%20Example%201.jpg Here is a version with the size variable moved to max. There is no increase in effect, just a shifting of the targeted pixels. http://i268.photobucket.com/albums/jj38/Humility1/The%20Unvieled%20Skirmishers%20Example%202.jpg And here is the final result. I show you this because you might want to see what the end goal was. Also I recall in this image in order to rapidly place the spikes on the flying creatures I had used the custom brush tool. Now one problem that tends to plague my drawings is that I have no good way of, well getting rid of that feathering effect that happens when I rotate stuff, resize and so on. And since I make lineart. they look really bad against the otherwise crisp black lines I make. http://i268.photobucket.com/albums/jj38/Humility1/The%20Unvieled%20Skirmishers.png And for a second example, these follow the same pattern with the same issues. My ice effect would have also been better with this tool I think. I forgot to remove the dark spots from my noise so I wasn't able to get the ice to gleam. And I didn't feel like undoing everything I already did. http://i268.photobucket.com/albums/jj38/Humility1/Balok.jpg http://i268.photobucket.com/albums/jj38/Humility1/Balok%20ex%201.jpg http://i268.photobucket.com/albums/jj38/Humility1/Balok%20ex%202.jpg http://i268.photobucket.com/albums/jj38/Humility1/Balok.png I do have images that a are far denser with so many splotches from eraser marks, sweat drops, smears, pencil burns ect that can take days to clean up. But they are fan art and I don't feel comfortable showing fan art. Even though the vast majority of what I draw is fan art and fan comics. Edited August 26, 2015 by Humility Quote Link to comment Share on other sites More sharing options...
Humility Posted August 26, 2015 Author Share Posted August 26, 2015 Took me two hours to make this post, I missed yours. Quote Link to comment Share on other sites More sharing options...
MJW Posted August 26, 2015 Share Posted August 26, 2015 Humility, I wrote a plugin which I believe does what you think you want done, though I'm not certain it will actually achieve what you want to achieve. It isn't a CodeLab pugin, so I'll wait to paste the code till I decide whether it's worth publishing. Here is the plugin, which I call Spot Remover (in Effects>Color): SpotRemover.zip Quote Link to comment Share on other sites More sharing options...
Humility Posted August 26, 2015 Author Share Posted August 26, 2015 (edited) I know its purpose isn't the kind that is really focused on here. Virtually all plug-ins and stuff focus on helping improve the end result. The quality of my own 'artwork' depends on how much time I put into it with the time being the limiting factor. Something like this that will work, will save me a lot of time and consequently improve my artwork. And I'm sure I'm not the only one. Its a plug in that will likely have no unique effect but if it works like I hope it should act as a short cut for a few things. Other then clean up, mostly in editting the colors of textures. Like when creating noise over say a light blue color when trying to make ice, one ends up with a lot of black and dark blue no matter what. Currently to deal with that one has to copy the area one is about to noisyfy, paste it to another layer, noise it up, wand the offending pixels, and then paint bucket them with global 100% and a transparent white. (Or fiddle with the cloud generator though I find its coverage not as satisfactory as pure noise) This would reduce all that to one step. And of course it would help deal with noise or textures you don't have the luxury of pre-seperating into layers. And would help fix jpgs. Edited August 26, 2015 by Humility Quote Link to comment Share on other sites More sharing options...
Humility Posted August 26, 2015 Author Share Posted August 26, 2015 Humility, I wrote a plugin which I believe does what you think you want done, though I'm not certain it will actually achieve what you want to achieve. It isn't a CodeLab pugin, so I'll wait to paste the code till I decide whether it's worth publishing. Here is the plugin, which I call Spot Remover (in Effects>Color): SpotRemover.zip I don't understand the significance of 'not a code lab plugin' does that mean it could blow up my computer or something? Quote Link to comment Share on other sites More sharing options...
MJW Posted August 26, 2015 Share Posted August 26, 2015 (edited) No, it just means the source code is longer than a typically short CodeLab program, so I decided not to post it all in a comment. If anyone is interested in seeing the code, I'll be happy to post it. I'll explain why I'm not sure it's really what you want. Suppose you have a smallish, blurry black dot, where the middle is pure black. and it gets lighter as it goes outward. When the tolerance is low, maybe only a few of the center pixels will match (and therefore be replaced), so you'll end up with a blurry black dot with a white center. If you increase the tolerance, the white center will grow, until enough pixels match the tolerance that the size of the matching region will exceed the count limit, at which point the entire dot will be black again. Edited August 26, 2015 by MJW Quote Link to comment Share on other sites More sharing options...
Humility Posted August 26, 2015 Author Share Posted August 26, 2015 well it won't do everything the plug-in I described would do. Like help recolor noise. But worth trying. Quote Link to comment Share on other sites More sharing options...
Humility Posted August 26, 2015 Author Share Posted August 26, 2015 (edited) Just tried it, it works very well. Thanks, will save me quite a bit of time. And it looks like it would even be able to help with the noise. In fact it seems to be exactly what I was requesting. Edited August 26, 2015 by Humility Quote Link to comment Share on other sites More sharing options...
Humility Posted August 26, 2015 Author Share Posted August 26, 2015 Actually not quite exactly for some reason its not having any effect on noise. I mean instead of grabbing the exact desired color and those within a close enough shade of it, it seems to be effecting randomly. And as I slid the bar around it suddenly stopped doing anything. Quote Link to comment Share on other sites More sharing options...
MJW Posted August 26, 2015 Share Posted August 26, 2015 There's always the possibility there's a bug in it, but it's also possible the apparent randomness is the sort of interaction I described between the tolerance and the region size. When you say "it quits working," do you mean for those particular settings, or do you mean that moving the controls ceases to have any effect? Quote Link to comment Share on other sites More sharing options...
Humility Posted August 26, 2015 Author Share Posted August 26, 2015 ceases to have any effect. Quote Link to comment Share on other sites More sharing options...
Humility Posted August 26, 2015 Author Share Posted August 26, 2015 Maybe it was the tolerance issue. As I found at 18 I seem to have all the dark ones now bright green. (I used bright green to better see.) But if I shift it up to 19 suddenly large random chunks revert. Though they don'r look like they should threaten to break the pixel size limit. Maybe its just a priority issue in the code. Because chunks that look identical seem unaffected and if I keep slowly raising the tolerance up chunks keep going from selected to unselected. I think though it froze before because I had just used TR's pixel tool before hand and there was some sort of conflict. As now that I've restarted it, there is no more problem with it stopping. Quote Link to comment Share on other sites More sharing options...
MJW Posted August 26, 2015 Share Posted August 26, 2015 (edited) ...and if I keep slowly raising the tolerance up chunks keep going from selected to unselected. That particular effect is probably a result of more pixels in the chunk meeting the tolerance threshold, until the size exceeds the size limit. EDIT: I think though it froze before because I had just used TR's pixel tool before hand and there was some sort of conflict. As now that I've restarted it, there is no more problem with it stopping. I wouldn't be completely shocked if it ceased working. I had that problem when I was initially testing it. I think I fixed the problem, and I couldn't get it to do that anymore, but there's always the possibility that there are still bugs of that sort. The algorithm is actually somewhat complex, using an extra surface and many flood fills, so there are plenty of places to go wrong. Edited August 26, 2015 by MJW Quote Link to comment Share on other sites More sharing options...
TechnoRobbo Posted August 26, 2015 Share Posted August 26, 2015 I'll have my version finished tonight, if uses a flood fill algorithm into a buffer, counts the pixels in the buffer then decides then sets the pixel on criteria. Quote Go out there and be amazing. Have Fun, TRSome Pretty Pictures Some Cool Plugins Link to comment Share on other sites More sharing options...
Humility Posted August 26, 2015 Author Share Posted August 26, 2015 It counts total pixels? And @MJW maybe but its certainly a good tool. Quote Link to comment Share on other sites More sharing options...
TechnoRobbo Posted August 26, 2015 Share Posted August 26, 2015 Yes it counts pixels - you're criteria was: Like say I might ask the plug-in to find contiguous areas of black, with a 1% tolerance and recolor any of these contiguous black areas comprised of 20 or fewer pixels into white. you can also choose to include or exclude diagonals as contiguous. BTW (Variance represents the euclidean distance between colors in an RGB 3D cube). TR's Speck Fill TRsSpecks.zip Menu: Effects ->Color CodeLab Source Code (it's just a little itty bitty thing) Hidden Content: // Name:TR's Speck Fill // Submenu: Color // Author:TechnoRobbo // Title:TR's Speck Fill v 1.1 // Desc: // Keywords: // URL: // Help: #region UICode int Amount1 = 10; // [0,128] Variance int Amount2 = 10; // [0,50] Size bool Amount3 = false; // [0,1] Diagonal Borders #endregion private double pythag(ColorBgra CP ,ColorBgra CP2 ) { return Math.Sqrt((CP.G -CP2.G) * (CP.G -CP2.G) +(CP.B -CP2. * (CP.B -CP2. + (CP.R -CP2.R) * (CP.R -CP2.R)); } private bool check(Surface s, int x, int y, ColorBgra f, int var ,int stop,bool diag ) { if (IsCancelRequested) return false; System.Collections.Generic.Stack<Point> que = new System.Collections.Generic.Stack<Point>(); int size=0; int[,] track = new int[Amount2 * 2 + 1,Amount2 * 2 + 1]; que.Push(new Point(x,y)); int limit = stop * 2 + 1; while (que.Count > 0) { Point p = que.Pop(); if (p.X < 0 || p.Y < 0 || p.X > (s.Width - 1) || p.Y>= (s.Height - 1))continue; Point pxy = new Point(p.X - x + stop, p.Y - y + stop); if (IsCancelRequested) return false; if (pxy.X > track.GetUpperBound(0) || pxy.Y > track.GetUpperBound(1) || pxy.X < 0 || pxy.Y <0) continue; if (track[pxy.X,pxy.Y]!=0)continue; if (pythag(s[p.X,p.Y],f)<=var) { track[pxy.X,pxy.Y]=1; p.Offset(1, 0); que.Push(p); p.Offset(-1, 1); que.Push(p); p.Offset(-1, -1); que.Push(p); p.Offset(1, -1); que.Push(p); if (diag) { p.Offset(1, 0); que.Push(p); p.Offset(0, 2); que.Push(p); p.Offset(-2, 0); que.Push(p); p.Offset(0, -2); que.Push(p); } } } for (int j = 0; j < track.GetUpperBound(1); j++) { for (int i = 0; i < track.GetUpperBound(0); i++) { if (IsCancelRequested) return false; if ( track[i,j] != 0)size++; } } return (size<=stop && size > 0); } void Render(Surface dst, Surface src, Rectangle rect) { Rectangle rect2 = EnvironmentParameters.GetSelection(src.Bounds).GetBoundsInt(); ColorBgra pc = (ColorBgra)EnvironmentParameters.PrimaryColor; ColorBgra sc = (ColorBgra)EnvironmentParameters.SecondaryColor; for (int y = rect.Top; y < rect.Bottom; y++) { if (IsCancelRequested) return; for (int x = rect.Left; x < rect.Right; x++) { if (IsCancelRequested) return; bool val = check(src,x,y,pc,Amount1,Amount2,Amount3); if (val) { dst[x,y] = sc; }else{ dst[x,y] = src[x,y]; } } } } 2 Quote Go out there and be amazing. Have Fun, TRSome Pretty Pictures Some Cool Plugins Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.