Red ochre Posted July 21, 2023 Share Posted July 21, 2023 Pdn 5.0.7 Running the built-in Noise/Median (default settings) on an object layer with background bgra = 0,0,0,0 changes this to bgra = 1,1,1,1. It does this for the whole layer regardless of distance from or even presence of an object. Test: Add new layer, use eye dropper to check values, run Median, check values again. It's the change in the alpha that is most annoying as it messes with effects that detect object edges but is visually indiscernible. Possibly small implications for file sizes too perhaps? I vaguely remember this issue from way back ... (quick search). I mentioned it in my Object Bevel thread in 2016. Just wondered if it's likely to be looked into? 1 Quote Red ochre Plugin pack.............. Diabolical Drawings ................Real Paintings Link to comment Share on other sites More sharing options...
Ego Eram Reputo Posted July 22, 2023 Share Posted July 22, 2023 6 hours ago, Red ochre said: Test: Add new layer, use eye dropper to check values, run Median, check values again. Repros for me. 1 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...
Rick Brewster Posted July 23, 2023 Share Posted July 23, 2023 I think this has been an issue ever since the Median effect was added to the app. Unfortunately I don't really understand the code -- I didn't write it, and it's fairly cryptic. Quote The Paint.NET Blog: https://blog.getpaint.net/ Donations are always appreciated! https://www.getpaint.net/donate.html Link to comment Share on other sites More sharing options...
Rick Brewster Posted July 23, 2023 Share Posted July 23, 2023 Also worth pointing out that any change to Median will affect any plugin that is using Median. I know @BoltBait has a bunch of these, and I think he even compensates for this issue. Quote The Paint.NET Blog: https://blog.getpaint.net/ Donations are always appreciated! https://www.getpaint.net/donate.html Link to comment Share on other sites More sharing options...
Rick Brewster Posted July 23, 2023 Share Posted July 23, 2023 That said, I think I see what the issue is -- I would just need to find a way to fix it without affecting plugins. And test, somehow, that it doesn't affect the results of Median too much. 1 Quote The Paint.NET Blog: https://blog.getpaint.net/ Donations are always appreciated! https://www.getpaint.net/donate.html Link to comment Share on other sites More sharing options...
Reptillian Posted July 23, 2023 Share Posted July 23, 2023 (edited) 48 minutes ago, Rick Brewster said: That said, I think I see what the issue is -- I would just need to find a way to fix it without affecting plugins. If the code is in rivy/OpenPDN, I can only guess that a conditional within "Apply" is all that is needed to fix median effect. I don't know, but the code itself is fairly cryptic as you said. Edited July 23, 2023 by Reptillian Quote G'MIC Filter Developer I am away from this forum for undetermined amount of time: If you really need anything related to my PDN plugin or my G'MIC filter within G'MIC plugin, then you can contact me via Paint.NET discord, and mention me. Link to comment Share on other sites More sharing options...
Red ochre Posted July 23, 2023 Author Share Posted July 23, 2023 Perhaps a simple and ugly 'bodge' after the Median code?... If the bug in the original code is not an easy fix. pseudo code: if(current pixel == ColorBgra.FromBgra(1,1,1,1)){current pixel = ColorBgra.FromBgra(0,0,0,0);} dst[x,y] = current pixel; @Rick Brewster Thanks for taking a look at the problem though!... correcting the original code would always be the better option, if possible. Quote Red ochre Plugin pack.............. Diabolical Drawings ................Real Paintings Link to comment Share on other sites More sharing options...
Rick Brewster Posted July 23, 2023 Share Posted July 23, 2023 No the fix seems like it's just changing, while (b < 255 & bCount < minCount) { bCount += hb[b]; ++b; } to while (b < 255 & bCount < minCount) { bCount += hb[b]; if (bCount < minCount) { ++b; } } in LocalHistogramEffect::GetPercentile(). (and the same pattern goes for the blocks of code afterward which are responsible for g, r, and a) The old code would always increment b,g,r,a to 1, it could never equal 0, but it seems like that should not happen if bCount was pushed to or past minCount. This method is only used by the Median effect so it won't affect the other LocalHistogramEffects (Outline, Reduce Noise, Surface Blur). 1 Quote The Paint.NET Blog: https://blog.getpaint.net/ Donations are always appreciated! https://www.getpaint.net/donate.html Link to comment Share on other sites More sharing options...
BoltBait Posted July 23, 2023 Share Posted July 23, 2023 5 hours ago, Rick Brewster said: Also worth pointing out that any change to Median will affect any plugin that is using Median. I know @BoltBait has a bunch of these, and I think he even compensates for this issue. I don't believe any of my GPU plugins use the Median effect. The only older style plugin that uses it is Oil Paint+ which works just fine if you fix this bug. Quote Download: BoltBait's Plugin Pack | CodeLab | and a Free Computer Dominos Game Link to comment Share on other sites More sharing options...
Solution Rick Brewster Posted July 29, 2023 Solution Share Posted July 29, 2023 Try the 5.0.8 beta and see what you think now: Quote The Paint.NET Blog: https://blog.getpaint.net/ Donations are always appreciated! https://www.getpaint.net/donate.html 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.