afre's G'MIC diary

???

in circulation. being used. That way I can see what people are doing downstream and whether my changes will be affecting other commands positively (new features) or negatively.

I was thinking searches toward commands would be enough, but yes a feature like that would be nice on developers side of things.

2019 review – 2020 goals

In Sept, I started making several of my long list of private commands public. It wasn’t easy to do because it was a hard year for me, with my father being in the hospital 3 times where they considered him a lost cause and not worth saving! to the day of his discharge, among other concurrent life challenges. (I knew he would make it each time!)

The response has been low but I would say that the ones that I have gotten have been positive and encouraging. At the very least, I had gotten around to entering dev world in a more tangible way than being app tester and forum supporter extraordinaire in these parts, among other things I found myself getting into. It has been an incredible distraction.

Looking forward, the beginning of 2020 will be for refining the existing set of commands in afre.gmic, which would fall under three categories: maintenance on older commands, artifact and bug squashing, and research and redevelopment. I bet you could guess which one has the highest priority but I would say that they are all closely related.

I would appreciate other kinds of feedback such as the exchange of ideas and ways to make them more efficient (after all, my weakness is math and coding, although some of you might disagree given what I have been able to accomplish; in any case, there is always room for improvement, right?). Anyway, as I have said in other places: Happy 2020!

1 Like

IF anything, you’re great at math. I have a hard time reading guided filter even if I know how it works at a code level.

Updates

1 afre_sharpenfft
– Address edge artifacts described previously. afre_contrastfft is fine as-is.
– Reexamining my private non-FFT sharpening commands. So far they aren’t as good.
strength Make parameter more assertive by increasing default and max values.

2 afre_softlight (important changes)
– Simplify to make less decisions for the user and improve GUI compatibility.
– It expects layers equal in size. (It no longer adaptively resizes, crops or centres.)
– Negative amount means inverse. (The inverse parameter is deprecated.)

2 Likes

I’d like to include your edge script in my neon filter since it generates some really nice lines!

Updates

1 afre_box Faster by kernel splitting.

2 afre_gui* Faster by afre_box improvement and new parameter faster, which down samples intermediaries and gives an approximate result. Sampling isn’t necessarily a bad thing: depending on taste, it may yield a desirable aesthetic.

Current interests (testing)

3 Sharpening My private non-FFT sharpening commands aren’t being released because they aren’t comparable to afre_sharpenfft but they do work well with it. A combo command is a possibility.

4 Guided filter It isn’t what I thought it was. The more I use it the more I realize it is yet another filter. There is still room for improvement. No guarantees on new developments. :stuck_out_tongue:

More updates

5 Maintenance In the process of tidying up afre.gmic, making commands and filters behave and look better; in particular, removing verbose commands and making echo and error commands more consistent.

6 ~New~ afre_conv is a generalized version of afre_box that takes 1-2 kernels, which will open up more options for the user and pave the way for interesting guided filters.
– If the user supplies one kernel [K1], the command will separate it for speed.
– If the user supplies two kernels, they will remain whole. If transpose_K2=1, K2 shall be transposed. This form [K1],[K2],1 is similar to Octave’s conv2.

1 Like

Updates

1 afre_halfhalf CLI GUI
I made a new convenience filter that puts 2 halves of 2 images together like a before and after. Currently, it only appends the halves horizontally. The match_size parameter controls whether the smaller side fills the far edge if the images’ dimensions don’t match.

match_size=0 (The preview in my screenshot is cropped at the edges. Up to no good again. :angry: Don’t fret, the output is perfect. :shamrock:)

match_size=1

doghalf

Match size doesn’t account for orientations other than portrait and landscape.

doghalf


Discussion on what I have been investigating.

The issue that I have been having with the guided filter is that its performance depends on finding an optimal set of parameters. Sure, it is an issue for most filters, but for blur, e.g., a decrease or increase in value yields predictable results. To find an optimal values, the processing time would inevitably be longer.

Goal #1 Write command that finds optimal parameter values in a reasonable amount of time and applies the guided filter based on its assessment.


Another issue with filtering is that an image typically has multiple scales of detail. That is where multi-scale algorithms are required. This will take time to investigate and develop — what a hobby! :slight_smile: Again, I would have to find optimal values: this time, not just for one filtering task but one for each scale, and also determine how many scales would be reasonable.

Goal #2 A multi-scale guided filter that also does #1 (not an easy feat).

Actual progress

I have been experimenting with ways to stabilize the haloing that comes from guided filtering. The attractiveness of guided is that it doesn’t halo as much and is faster than filter that don’t generate (obvious deleterious) halos, which is why I love it and why FLOSS raw processors are using more and more of it the past year or so.

Anyway, at the moment, it is more show than tell. One technique looks promising. It isn’t perfect at some edges where it can differ by a radius width (hopefully not in a jagged manner). In the sailboat below, you can see the mast is a little thicker at one point. It is actually a bit like that in the original crop but a little more bothersome. Another issue is that it will call afre_gui0 8 times. If you are using slow settings, then you are going to have to wait for a while. That said, if it were not for G’MIC scripting, it would still be faster or just as fast as other filters because guided filtering is a fast technique.

From Play Raw How to improve this view (crop).

_crop

Test guided filter

_side

Difference

_diff

Sample tiger. Take note of the whiskers and the fur on the nose.

Test guided filter

Difference

Updates

1 *New* afre_gui2 is afre_gui0 with the ability to take in 2 kernels for added customization. It uses afre_conv to do that (which can use 1 or 2 kernels, so I might add that flexibility to afre_gui2 later).

2 *Change* afre_conv uses transpose_k2=0 by default now.


@Silvio_Grosso I upped afre_compare. It was my private convenience command to crop a subsection of the images and then place the images side-by-side for comparison along the x, y or z axis. Moreover, you may choose not to crop or crop twice for precision.

The neat thing about the cropping is that you could use the mouse wheel to scroll through the images to ensure you are finding the right region. This can be useful if each slice is significantly different, which makes me think that I might want to offer a normalization step to enhance the visualization (Edit done!).

1 Like

Hello @afre,

I suppose is it not implemente in the Qt GUIs, right?
Just looked for it with Gimp 2.10.18 - G’MIC 2.8.4 (on Windows 10)
There are many filters, in the testing part, belonging to you but not afre_compare

I have also tried the 2.9 CLI version of G’MIC (just updated now the filters).
However, in all truth, I don’t know how to use this filter.
In essence, whay I am supposed to type in the CMD.
For instance, If I type only afre_compare, this command opens the 2 images, side by side, but I don’t know what to do afterwards (it looks like they are both stuck together)

I have also looked in your previous comments, on this same thread (afre’s G’MIC diary), in order to find some more details about this filter…

That is all it does. :upside_down_face: A quick way to examine one region of one image and its modified copies. Quit Esc and redo the command.

I could make it a loop so that when you press Esc you could select another region for comparison. Would that be useful?

Anyway, here is a GIF of it in action. I am not good at making demos but here goes. :blush:

1 Like

Ok.

The GIF is quite self-explantory.
I need to play a bit with this filter and I report back :slight_smile:

As usual, thanks a lot for your help on this forum: it is quite appreciated!

I have yet to figure out how to do interactive filter, but that’s an accomplishment you did.

Updated afre_compare to include normalize and factor in channel variability. For the fun of it, changed axis to take in the actual letters x, y and z.

crop={ 0=don't | 1=once | 2=twice },_axis={ x | y | z },_normalize={ 0 | 1 }
Default value: 'crop=0', 'axis=x' and 'normalize=1'.

ATM, it can be unweildy if you are comparing many images on the x or y axis. If there is a demand, I may consider displaying them in a grid instead. Let me know what you think.

Why not try the c-axis as in the 4th dimension?

I don’t see the visual utility. :confused:

I was just kidding bro.

Hello @afre

Just tested your filter.
As usual, with 2 jpeg images after just updating G’mic (10:05 a.m)
Windows 10 - 64 bit

Here is my question:
how can I get back to the not zoomed (magnified) image?
With the CLI G’MIC I am used to double click into the image and the zoom is resetted. This shortcut (clicking) does not work here and the image remained zoomed-in.
If I press ESC the filter is closed and I am forced to repeat the command once again.

From your G’MIC command, which I have shamefully copied:
gmic.exe 1_basso.JPG 2_alto.JPG +afre_edge 1 to_rgb. afre_compare 2,0
I gather that I:

  • first apply an edge_filter;
  • then I “cast” to the rgb color space mode;
  • finally, in the pipeline, I apply the afre_compare filter (the one I really need…);
  • this final option (2,0) throws an error on the CMD prompt (2,0).

EDIT:
Another small problem occurs since I don’t know how to “strenghten” the edge filter. With 1, as setting, I can hardly see the “edges” of my images (most of them are fungi, btw).

Here is a screenshot with the problem I am facing right now.
In short, I don’t know how to zoom-out from this selection and get back to visualize the whole image (double-click doesn’t work and Esc closes the window, as expected):

As said above, this is a limited command, but I am willing to loop the command once I figure out how to exit gracefully (to do).

Try this instead. gmic update first because I have made a change since the GIF.

gmic lucertola.jpg +b 1 +afre_edge 1 afre_compare 1,x,1

afre_compare
– First parameter (e.g., 1=once) is the amount of times you want to crop interactively.
– Second is the axis (e.g., x=x-axis) that you want to compare the crops.
– Third is whether you want to normalize (e.g., 1=yes).

afre_edge
– First parameter is for thinning if 1 is too thick.
– Second is for recovery because thin lines are hard to see. It brings back some intensity.
– Third is for brightness. Functionally works to enhance recovery.
– Fourth is to dampen or enhance details. Higher numbers generate a web-like appearance.

When in doubt, do gmic help afre_compare or gmic help afre_edge to recall what to do, or to become acquinted with any changes I have made. I develop incrementally, so things change rapidly. Of course, I try to post about it in this thread but clearly it wasn’t understood so I am elaborating for your convenience.