afre's G'MIC diary

Not to mention some people don’t really want to create an account. I know there are people out there watching my work.

PS Hint: add G’MIC to the list of environment variables. That way you can access G’MIC from the console by simply typing gmic from any directory.

Already done… :slight_smile:
Anyway thanks for the reminder…

But for some reason I can only open the directory of G’MIC by typing:
%gmic%
in the WIND+R window (see screenshot below for the exact command):

gmic_ok

Afterwards, I open the *.exe through the PowerShell of Windows 10

Whenever I try on the CMD prompt the path is not recognized…
This applies to other softwares as well (e.g. PostgreSQL etc).
In the end, I often forget about the Wind+R (shortcut) and I navigate through the folders with the command “cd” (which is quite time-consuming, I know…)

Here are my variables on Windows 10 (italian GUIs…)

EDIT
My bad
If I type cd %gmic% in the CMD prompt it works (the gmic path pointing to its folder is recognized)!
Thanks a lot for prompting me to check it once again

I forgot to mention, adding gmic to env var makes life easier. I actually prefer g’mic scripting with cli now though I will use gui at times.

@Silvio_Grosso Add to user path, then you can use it directly while located in any folder.

image


PS

It is a bug of the interactive crop that happens once in a while. If you look at your screenshot carefully, there is a small display window with a single black pixel. I will report it once I can reproduce it. (You can help investigate if you want.)


Update #1
afre_compare can now do any number of queries. To exit the command, close the crop windows or click in them once without dragging. See description of the updated command below:

afre_compare:
    crop={ 1=once | 2=twice },_axis={ x | y | z },_normalize={ 0 | 1 }

  Crop then compare.
  Default values: 'crop=1', 'axis=x' and 'normalize=1'.

  1. Interactive Crop
   - Click and drag to select crop.
   - Use scroll button to browse images.
   * Click once or close window to exit command.

  2. Comparison Window
   - Regular display behaviour.
   - Close window to make another comparison.

Bugs
– Crop parameter no longer takes 0. Forgot to change defaults. Fixed
– Should check that command only takes 2+ images. Fixed
– After an iteration, possibly fewer images than starting number. Fixed
– Should check for matching image dimensions w, h and d>1. Fixed


Update #2
Cleaned up afre_conv _box _gui*. afre_conv and afre_gui2 now only take in only one custom kernel, which is all they need. If user has more than one kernel, they can combine them or repeat the commands.

Important updates

A. I improved the guided filter. The obsession has not gone to waste. :partying_face: It has better edge preservation, perhaps too aggressive in some cases. It is only available in afre_gui0 at the moment (once update*.gmic updates).

B. I will be removing the faster parameter in afre_gui*. It degrades the performance of the filter and is incompatible with the new method.

C. To mitigate harsh edges, I am adding a structure parameter. Reducing the value will soften edges and suppress artifacts.

Highlights

D. If you haven’t already tried afre_cleantext, please do so. I am using it regularly for document and signature scans and photos.

E. afre_compare is helpful when I want to make quick comparisons of various regions of multiple images. I believe this command has a lot of potential. There are plenty of features that I could add: stats, saving and more display modes.

F. afre_edge is good for stats and use in other commands. I will be adding two more edge modes once I finish working on afre_conv, _box, _gui*, etc.

That is all I will share for now. :slight_smile: Have a safe week, love your neighbour and happy processing!

1 Like

Is that a prelude to taking on a challenge? I do love how your short script does a lot for what they do.

Important update (Part II)

Remember, you must update to at least G’MIC 2.9.0 and update your commands to enjoy the latest improvements and bug fixes.

afre_gui* all use the same method now. Made more commits than I expected: easy to make mistakes when changing code but hard to debug. Let me know if you experience any anomalies.

afre_gui2 has a name change: it is afre_gui0c now. It allows the user to specify a custom convolution kernel.

– Likewise, afre_gui1c (new) is afre_gui1 with kernel customization.

Afre, is naming commands into more descriptive one is a option?

On naming commands

Long names can be tedious to type and shortcuts difficult to recall. Concise names promote readable code. When in doubt, the user may use help; or make a shortcut of their choosing, although I would advise against the latter, in the service of open source, where attribution and keeping track of where my commands are being used is important to me.

Here is an explanation of the current naming scheme of the afre_gui* series of commands. Initially, my plan was to make one master guided filter. I decided against that because it made the code unnecessarily difficult to write, debug and review.

afre → me :hushed:
gui → guided filter :guide_dog:
0 → self-guided · 1 → other-guided :thinking:
c → custom kernel :popcorn:

This helps me keep track of them and allows me to make more. Yes, there will be more of these.

Short update

Worked on the guided filter some more. I always had trouble filtering noisy images. If you have seen my PlayRaws you would know what I mean: splotchy on most images but an awesome frosted glass effect on noisy blurs. Anyway, I made progress on this front. Still a few things to sort out such as a newly discovered NaN bug (edit no such bug: was feeding the command a bad guide image). Aside from that, it looks good so far.

Request from readers: please send or link me noisy test images with a wide dynamic range and noise mixed in with detail and structure. I prefer images without compression artifacts (e.g., TIFs or RAWs+sidecars). Thanks!

4 Likes

I have to say that the denoising is quite excellent. If you are willing to accept suggestion, perhaps controlling noises on the luminosity side of thing would improve it.

Sorry folks, I may have misled you. Or maybe I landed on genius in my bout of insomnia, which has happened many times before. The issue is that I can’t reproduce the denoising shown in my previous post. I am left with the result below. :blush:

For what it worth, that can be a oil pastel filter. It can take days to figure out how to reproduce a result (this is speaking from experience). Maybe even weeks or months at times.

Most likely it was just me filtering a noiseless image because it is awfully close to that, or the noise-stars aligned and I got lucky. Next thing to do is to test what I have on other images and noise types.

That’s looking pretty good for the type of noise reduction it is. You’d have to go to the frequency domain to pull out the texture of the pencils I think.

Thanks for the hint. If you have any tips or examples, that would be great. A little help goes a long way for me. Be gentle though. I have trouble following your *.gmic file. :stuck_out_tongue:

For comparison, here is the result from denoise_patchpca using default parameter values. Takes 100x longer.

pencil_pca

I think a more reliable comparison is having more pictures to go on by. denoise_patchpca doesn’t seem to work for that image. It reminds me a bit of AI art error where you see those weird patches.

You know, I think I may provide you a thorn fractal noisy image with variety of colors tomorrow or two. I feel like doing that, but it’s late here.

Even I have trouble following my gmic file :wink:

Here is the result from my Noise reduction filter, which is much more complicated.

pencils

The main difference is your result has some colour smearing which is always a problem, especially if you are using a luma/chroma colour space like Lab or Ycbcr.

With regard to tips. Although I haven’t even looked at your gmic file, so I might be telling you something you already know.

There are two avenues you could pursue:

  1. Consider the guide image you are using. You can manipulate the guide image to improve the noise reduction. For example, my filter has the ‘soften guide image’, which is a small radius blur on the guide to knock back impulse noise. You can do all kinds of manipulation to the guide and see if it helps. For example, you could try improving colour edges by increasing saturation at edges (or decreasing saturation away from edges) in the guide.
  2. Use your filter in multiscale. Your result suffers from low frequency blotches, which are easy dealt with on a scaled-down version of the image. You may find you need to do less noise reduction on the full-size image if you are dealing with blotches on other scales.
1 Like

Here is a test image I use for noise reduction tests. It from a humble 6-megapixel D40, which is about the right amount of pixels when you are working with slow algorithms.

1 Like