GMIC Frame and GMIC Hough Sketch

Possible GMIC filter error in Artistic/hough sketch?

I encountered this problem, while doing some tests:

case A:
1.open an image
2.apply GMIC/Artistic/Hough Sketch (I use output on new active layer)
3.result OK. evident sketching lines on the image

case B:
1.open an image
2.add a frame using GMIC/Frames (blur)
3.result OK, image framed
4.apply GMIC/Artistic/Hough Sketch (I use output on new active layer)
5.result not OK. an almost totally white layer

It seems that Hough Sketch does not work properly on a frames image.

Verified already by Nelo and Rich on different environments

My environment:

  • Winfows 10 up to date (my hardware does not support Windows 11)
  • GIMP 2.10.32 (samjā€™s pack)
  • GMIC 3.2.4

Is it related to the presence of an alpha-channel ?
Does it work if you just open an image, add an alpha channel, and test the filter ?

Bonjour,

It seems that a problem exists with the current version of fx_houghsketchbw
This filter ā€˜blocksā€™ when a united color contour is present.
The old filter works. It is always ā€˜presentā€™ using for example:

samj_fx_sketchbw_modifie 3,45,180,30,1.75,0.02,0.5,0.75,0.1,0.7,3,6,0,1,4,0,1234,0,2,94,0.2,1,4,1,0

:o)

Reply to David:
with or without alpha channel the error occurs.
It has been tested also by Rich.
Reply to samj:
yes, your version modified works fine; should this be used instead or will the standard version be amended (David)?

@dinasset
@David_Tschumperle

Bonjour,

I confused fx_houghsketchbw and fx_sketchbw :o(

I attach an image example where fx_houghsketchbw does not work.
Here, it is the white square that poses a problem.

You have to try to delete the straight lines of the image.

A test on the previous image with ā€˜rippleā€™.

ripple 10,45,2,30,0
fx_houghsketchbw 1.25,10,5,80,0.1,4,0,50,50

Good trick, thanks.
I still hope for a correction of the houghsketch (GMIC) by David, even if that implies a change to the hough sketch mathematics, as explained by Grosood on the Gimpchat post which started the discussion.

Hello, @dinasset. Ages since we have corresponded. Rectangular tiling, in the event that memory serves :wink: .

Alas, Methinks we deal with a feature, not a bug.

First, to purposes. fx_houghsketchbw visualizes voting tallies called theta-rho maps, after the Greek letters (Īø,Ļ). These inventory the orientations and displacements from origins of lines traversing two-dimensional planes. Hough surveys images and produces such inventories. Here is how the scheme goes along.

First, consider one line from such an inventory:
thetarho

A rotation, Īø, then a displacement, Ļ, from the origin to the traversing line ā€” at the intersection, and crossing at right angles ā€” serves to uniquely identify L, the traversing line. Most of us would reach for the more familiar slope ( m ) and y-axis intercept ( b ), from y = mx + b to classify lines, but infinite slopes, possessed by those lines perpendicular to the x axis, pose computational difficulties in many practical settings. See Wikipediaā€™s Hough transform for the sordid details. For that reason, we frequently turn to this theta-rho tabulation, as these parameters can readily cope with vertical orientations.

As it is a unique numeric pair, we can readily situate L on a theta-rho map, using (Īø,Ļ) as coordinates:
thetarho_map
with Īø being ā€˜x-likeā€™ and Ļ being ā€˜y-likeā€™.

The lot of Gā€™MICā€™s hough command is to survey arbitrary images and tabulate ā€˜something akinā€™ to theta-rho maps ā€” the differences in encoding between such maps and what hough actually produces I beg not to take up now, but the essential gist of it is that a great deal of up-voting occurs at (Īø,Ļ) intersects in the theta-rho map corresponding to lines where a great many pixels align. That strong upvote is what hough tabulates, part-and-parcel with its mission of extracting line-like features out of images. The strong upvotes identify the strong lines of interest.

fx_houghsketchbw is a bit of whimsy that reverse-engineers the maps that hough produces, drawing the strong lines of interest as listed in the tabulation. What is obtained from this reverse engineering is an image that ghosts the original ā€” that is the whimsy part. It is as if I was constrained only to drawing lines of select orientations and displacements. This trio of images illustrate what hough and fx_houghsketchbw are about:


It is worth noting the image metrics of the voting tally image: thetarho:

[1] = 'thetarho':
  size = (512,512,1,1) [1024 Kio of float32].
  data = (3.31251,11.0466,0,0,5.50909,0,0,3.29881,2.28675,0,6.16836,0,(...),0,0,0,0,0,0,0,0,0,0,0,0).
  min = 0, max = 390.875, mean = 4.21341, std = 9.46725, coords_min = (2,0,0,0), coords_max = (189,259,0,0).

Consider iM=390.875. That suggests the presence of a line at some (Īø,Ļ) intersect which has received nearly 400 votes ā€” a strong candidate, I suspect it may correspond to a hough-line coincident, or nearly so, to where her right cheek contrasts with her hair. Other candidates are possible, and all are of the ilk of nearly line-like features coincident with like strong features in the original image.

Let us now take up the consequences of framing:


The frame introduces four horizontal and four vertical edges that each contrast with surrounding ambient luminance and run nearly the length and width of the image ā€” Just the sort of feature that garners high votes in hough's tally. Indeed, image metrics of the framed-image theta-rho map tells us as much:

[2] = 'thetarho':
  size = (666,666,1,1) [1732 Kio of float32].
  data = (15.9612,4.91599,11.0466,0,0,0,0,2.00368,3.4665,3.29881,4.92585,0,(...),0,0,0,0,0,0,0,0,0,0,0,0).
  min = 0, max = 67601.8, mean = 4.50687, std = 251.885, coords_min = (3,0,0,0), coords_max = (0,379,0,0).

A (Īø,Ļ) intersect with an intensity of 67,601.8 garners nearly 173 times the up-votes of the strongest linear feature in the previous image, that of face sans frame. The image of the theta-rho map concludes the story: eight bright dots that, with their five figure intensities, mark the eight edges comprising the border and swamp all the other votes. Since the pipeline culls relatively low-vote (Īø,Ļ) intersects, most lines that would otherwise construct the face are dropped out: they are low-vote noise. Quod erat demonstrandum.

So the ā€˜bugā€™ coincides with the quintessential design of hough. There may be difficulties in convincing @David_Tschumperle to fix such.

Perhaps, then, reverse the operations of fx_houghsketchbw and fx_frame_blur? To wit: sketch the original, then frame, instead of framing the original, then sketching? Or am I missing something?

Have fun, however you may proceed.

I added a small filter combining Ripple and Houghsketchbw

Garry,
Itā€™s always interesting to read your ā€œmathematicalā€ explanations.
As you know, Iā€™m a bit practical user, and my point is:

  • either an algorithm is used to obtain a graphical result always almost acceptable or it should not make part of a graphical software like GMIC
    This algorithm (Hough) does not produce an acceptable result when the image contains straight lines somewhere, hence it should not be part of a graphical application like GMIC (or it has to be partially modified to take care of straight lines). It is not a problem of the frame: any image with straight lines produces wrong (graphically, not mathematically) result. Anybody can try this.

Thanks Sylvie.

edit:I inserted the call at your test filter when user asks for effect Hough Sketch.
It works fine.
Thanks again

Just to complete my reply to Garry:
-source image: This is an image without frame, simply architectural with straight lines in it (usual landscape image)
-outcome: what we get with GMIC Hough Sketch
I donā€™t think anybody can be satisfied with such a result.
So my point is: if we want to maintain that filter in GMIC the only solution is to include some additional trick to avoid the ā€œpurelyā€ mathematical ā€œbadā€ result.

The point is : itā€™s not just about adding ā€œa trickā€. This means changing a part of the algorithm, and this may be quite difficult BTW.
Iā€™ve done a change this morning (already took me 25 mn to figure out which), but Iā€™m not sure this really improve the whole thing. Please test and tell me about it.

2 Likes

Thanks David.
My first test:

  • applying the mod version to an unframed image
  • applying the mod version to a framed image
    Outcome framed shows areas internally close to the white square framed image with a softer texture.
    This outcome is much more acceptable -by an artistic viewpoint-.
    Thanks a lot

2 Likes

@David_Tschumperle

Bonjour,

Thank you very much for this beautiful improvement, the rendering is very pretty :o)


@dinasset

Thank you very much for the tests and this thread :o)


I attach 2 results and the command lines.

On the left the one with the new houghsketchbw filter and on the right the one with ripple.

Code for Gā€™MIC-QT:

rm
sp colorful
fx_frame_blur 30,30,0,5,0,0,128,128,128,0,5,255,255,255,2,2,1,0,0.5,0.5,0
+fx_houghsketchbw 1.25,23.03,5,80,0.1,4,0,50,50
samj_ripple_houghsketchbw.. 2,153,50,1,45,0,23.03,5,80,0.1,71.94,1,17,1,0,0
fx_montage 2,"V(H(0,1),H(2,V(3,4)))",1,0.5,0,20,255,255,255,255,0,0,0,1,0
1 Like