Descreen Filter Weirdness

I used the Descreen filter on this particular image and is ends up doing some sort of color filtering instead. I tried Descreen on a bunch of other images and it seems to work just fine, but this image just won’t work with the filter.

AFAICT, the image properties are the same as other images it works on so I’m a bit miffed. Here is a split view of the before and after of the Descreen filter.

Were you using this command?


fx_pahlsson_descreen : -skip $*
-pahlsson_descreen
fx_pahlsson_descreen_preview :
-gui_split_preview "-fx_pahlsson_descreen 0",$-1
pahlsson_descreen :
-repeat $! -l[$>] -split_opacity -l[0] -to_rgb
-rgb2cmyk
-split c
-name[-4] C
-pahlsson_descreen_channel[-4]
-name[-3] M
-pahlsson_descreen_channel[-3]
-name[-2] Y
-pahlsson_descreen_channel[-2]
-name[-1] K
-pahlsson_descreen_channel[-1]
-append c
-cmyk2rgb
-endl -a c -endl -done
pahlsson_descreen_channel :
basename={0,b}
-name[0] original
crop1=0,0,{original,w-1},{original,h-1},0
crop2=0,{original,h},100%,100%,0
-float2fft8[original]
-name[original] fft
-i [fft]
-name[-2] real
-name[-1] imaginary
-crop[real] $crop1
-crop[imaginary] $crop2
-i [real]
-name[-1] mask
-dog[mask] 0.5%,0.8%
-normalize[mask] 0,255
-threshold[mask] 64
-normalize[mask] 0,255
-negate[mask]
-ellipse[mask] 50%,50%,7%,7%,255,255,255,255
-i [mask]
-name[-1] blurmask
-blur[blurmask] 1.6%
-normalize[blurmask] 0,255
-mul[mask,blurmask]
-div[mask] 256
-mul[mask,real]
-div[real] 256
-append[real] [imaginary],y
-name[real] fft
-remove[imaginary]
-fft82float[fft]

You can check by going into the G’MIC settings menu and going to the ‘Other’ tab where you’ll be able to set the ‘output messages’ setting to something that will tell you the command and the parameters you used.

IMO that looks like a memory error or something due to the sharp boundary and the fact that it’s affected a portion of the blue channel only.

For anyone else reading this, You most likely want to choose (very verbose log file) to get useful results for troubleshooting. Plain (verbose log file) wasn’t very verbose with only 2 lines, and debug created a file almost 4mb in size.

Here are the results:

[gmic]-0./ Start G'MIC interpreter.
[gmic]-0./gui_filter_sources/ Skip argument '1,1'.
[gmic]-0./gui_filter_sources/*if/ Start 'if...endif' block -> condition '1' holds.
[gmic]-0./gui_filter_sources/*if/ Set local variable 'local=/home/akovia/.config/gmic/update291.gmic'.
[gmic]-0./gui_filter_sources/*if/*if/ Start 'if...endif' block -> condition 'isfile(['/home/akovia/.config/gmic/update291.gmic'])' holds.
[gmic]-0./gui_filter_sources/*if/*if/ Import commands from file '/home/akovia/.config/gmic/update291.gmic' (2013 new, 2185 replaced, total: 4171).
[gmic]-0./gui_filter_sources/*if/*if/gui_filter_sources/ Input image at position 0, with values (104,116,116,112,115,58,47,47,103,109,(...)116,101,50,57,49,46,103,109,105,99,1) (1 image 31x1x1x1).
[gmic]-0./gui_filter_sources/*if/*if/gui_filter_sources/*local#42849/ Input file '_gui_filter_sources' at position 0
[gmic]-0./gui_filter_sources/*if/*if/gui_filter_sources/*local#42849/ e[0;31;59me[1m*** Error (file '/home/akovia/.config/gmic/update291.gmic', line #42849) *** Unknown command or filename '_gui_filter_sources'; did you mean 'gui_filter_sources'?e[0;0;0m
[gmic]-0./gui_filter_sources/*if/*if/gui_filter_sources/*local#42849/ Remove image [] (0 images left).
[gmic]-0./gui_filter_sources/*if/*if/gui_filter_sources/*local#42850/ e[0;31;59me[1m*** Error (file '/home/akovia/.config/gmic/update291.gmic', line #42850) *** Unknown filename '/home/akovia/.config/gmic/gui_filter_sources'.e[0;0;0m (1 image 18x1x1x1).
[gmic]-2./gui_filter_sources/*if/*if/ Return.
[gmic]-2./ End G'MIC interpreter.

[gmic_gimp_qt]./preview/ v 3 fx_pahlsson_descreen_preview 0

[gmic_gimp_qt]./preview/ v 3 fx_pahlsson_descreen_preview 0
[gmic]-1./ Start G'MIC interpreter.
[gmic]-1./ Abort G'MIC interpreter (caught abort signal).[gmic]-1./ Start G'MIC interpreter.
[gmic]-1./fx_pahlsson_descreen_preview/gui_split_preview/ Import custom commands from expression '_split_preview : -fx_pahlsson_descreen 0 k[0]' (1 new, total: 4172).
[gmic]-1./fx_pahlsson_descreen_preview/gui_split_preview/ Set local variable 'is_movable=0'.
[gmic]-1./fx_pahlsson_descreen_preview/gui_split_preview/ Set multiple variables 'posx=50', 'posy=50'.
[gmic]-1./fx_pahlsson_descreen_preview/gui_split_preview/ Set multiple variables 'pw=376', 'ph=834'.
[gmic]-1./fx_pahlsson_descreen_preview/gui_split_preview/*repeat/*local/ Set local variable 'is_failed=0'.
[gmic]-1./fx_pahlsson_descreen_preview/gui_split_preview/*repeat/*local/*local/ Apply command '_split_preview' on image [0], with a timeout of 015 seconds.
[gmic]-2./fx_pahlsson_descreen_preview/gui_split_preview/*repeat/*local/*if/ Keep image [1] (1 image left).
[gmic]-1./fx_pahlsson_descreen_preview/gui_split_preview/ Discard definition of custom command '_split_preview' (1 found, 4171 commands left).
[gmic]-1./ End G'MIC interpreter.

[gmic_gimp_qt]./apply/ v 3 fx_pahlsson_descreen 0
[gmic]-1./ Start G'MIC interpreter.
[gmic]-1./fx_pahlsson_descreen/ Skip argument '0'.
[gmic]-1./fx_pahlsson_descreen/pahlsson_descreen/*repeat/*local/ Split color and opacity parts of image [0].
[gmic]-1./fx_pahlsson_descreen/pahlsson_descreen/*repeat/*local/*local/ Force image [0] to be in RGB mode.
[gmic]-1./fx_pahlsson_descreen/pahlsson_descreen/*repeat/*local/*local/ Convert color representation of image [0] from RGB to CMYK.
[gmic]-1./fx_pahlsson_descreen/pahlsson_descreen/*repeat/*local/*local/ Split image [0] along the 'c'-axis.
[gmic]-4./fx_pahlsson_descreen/pahlsson_descreen/*repeat/*local/*local/ Set name of image [0] to 'C'.
[gmic]-4./fx_pahlsson_descreen/pahlsson_descreen/*repeat/*local/*local/ Set name of image [1] to 'M'.
[gmic]-4./fx_pahlsson_descreen/pahlsson_descreen/*repeat/*local/*local/ Set name of image [2] to 'Y'.
[gmic]-4./fx_pahlsson_descreen/pahlsson_descreen/*repeat/*local/*local/ Set name of image [3] to 'K'.
[gmic]-4./fx_pahlsson_descreen/pahlsson_descreen/*repeat/*local/*local/ Append images [0,1,2,3] along the 'c'-axis, with alignment 0.
[gmic]-1./fx_pahlsson_descreen/pahlsson_descreen/*repeat/*local/*local/ Convert color representation of image [0] from CMYK to RGB.
[gmic]-1./fx_pahlsson_descreen/pahlsson_descreen/*repeat/*local/ Append image [0] along the 'c'-axis, with alignment 0.
[gmic]-1./ End G'MIC interpreter.

[gmic_gimp_qt]./preview/ v 3 fx_pahlsson_descreen_preview 0
[gmic]-1./ Start G'MIC interpreter.
[gmic]-1./fx_pahlsson_descreen_preview/gui_split_preview/ Import custom commands from expression '_split_preview : -fx_pahlsson_descreen 0 k[0]' (1 new, total: 4172).
[gmic]-1./fx_pahlsson_descreen_preview/gui_split_preview/ Set local variable 'is_movable=0'.
[gmic]-1./fx_pahlsson_descreen_preview/gui_split_preview/ Set multiple variables 'posx=50', 'posy=50'.
[gmic]-1./fx_pahlsson_descreen_preview/gui_split_preview/ Set multiple variables 'pw=376', 'ph=834'.
[gmic]-1./fx_pahlsson_descreen_preview/gui_split_preview/*repeat/*local/ Set local variable 'is_failed=0'.
[gmic]-1./fx_pahlsson_descreen_preview/gui_split_preview/*repeat/*local/*local/ Apply command '_split_preview' on image [0], with a timeout of 015 seconds.
[gmic]-2./fx_pahlsson_descreen_preview/gui_split_preview/*repeat/*local/*if/ Keep image [1] (1 image left).
[gmic]-1./fx_pahlsson_descreen_preview/gui_split_preview/ Discard definition of custom command '_split_preview' (1 found, 4171 commands left).
[gmic]-1./ End G'MIC interpreter.

So this was a good way to see all the old or corrupt faves, so I was able to remove them all. Unfortunately, it made no difference to this descreen problem. I see the errors, but not sure what to make of them.

I did notice quite a few empty files in my .config folder. Here is a directory listing with file sizes.

$ tree -s
.
├── [       5641]  gimp_faves
├── [    1997151]  gimp_update1652.gmic
├── [    1977113]  gimp_update1661.gmic
├── [    1996189]  gimp_update167.gmic
├── [    2123146]  gimp_update168.gmic
├── [    2137458]  gimp_update169.gmic
├── [    2149997]  gimp_update170.gmic
├── [    2193537]  gimp_update172.gmic
├── [          0]  gimp_update.lock
├── [      16732]  gmic_qt_faves.json
├── [       5358]  gmic_qt_log
├── [       7390]  gmic_qt_params.dat
├── [       7415]  gmic_qt_params.dat.bak
├── [         63]  gmic_qt_visibility.dat
├── [      72037]  grain_kodak_tmax3200.cimgz
├── [      81739]  grain_kodak_tmax400.cimgz
├── [      71813]  grain_orwo_np20.cimgz
├── [       1316]  hotchocolate.gmic
├── [     177832]  sample_barbara.png
├── [     371659]  sample_landscape.png
├── [    1384219]  style_greatwave.png
├── [    1428730]  style_landscapenearantwerp.png
├── [    1340166]  style_leviaducalestaque.png
├── [    1140474]  style_littlebayatlaciotat.png
├── [    1424579]  style_portraitdemetzinger.png
├── [    1623330]  style_themandola.png
├── [    1631883]  style_windowsopensimultaneously.png
├── [          0]  update222.gmic
├── [          0]  update223.gmic
├── [          0]  update230.gmic
├── [          0]  update231.gmic
├── [          0]  update232.gmic
├── [          0]  update233.gmic
├── [          0]  update235.gmic
├── [          0]  update236.gmic
├── [          0]  update240.gmic
├── [          0]  update241.gmic
├── [          0]  update242.gmic
├── [          0]  update243.gmic
├── [          0]  update244.gmic
├── [          0]  update245.gmic
├── [          0]  update253.gmic
├── [          0]  update261.gmic
├── [          0]  update263.gmic
├── [          0]  update267.gmic
├── [          0]  update270.gmic
├── [          0]  update275.gmic
├── [          0]  update280.gmic
├── [          0]  update281.gmic
├── [          0]  update282.gmic
├── [          0]  update283.gmic
├── [          0]  update284.gmic
├── [          0]  update290.gmic
└── [    4370036]  update291.gmic

Thanks

First, you don’t need to care about the empty files. They were once for previous versions of the community list of commands which can be found here: GitHub - dtschump/gmic-community: Community contributions to the G'MIC software.

_gui_filter_sources only appears once, and only affects fetching new filter sources, so it’s nothing to do with the image.

I think you will need to enable debug to see just what the thing is doing - or alternatively take apart the entire fx_pahlsson_descreen command by commenting bits of it out and seeing what’s messing up. My first thought is that crop2=0,{original,h},100%,100%,0 should instead be crop2=0,{original,w},100%,100%,0. A clue would be that the distortions appear to fit neatly into a square portion of the image. That’s just for comparison. Now I’m thinking that it’s to do with the FFT on the cyan channel since those artefacts look FFT-ish to me.

@akovia

1 Since this is a copyrighted work (or derivative), I suggest you find another image to use as a sample. Alternatively, edit your post to include a low resolution version to fit fair use territory (which is grey area).

2 We can’t help you if you don’t show your parameters. Please screen shoot the plugin.

3 There is also a descreen filter by @Iain called Grey_Descreen.

I appreciate the help, but it has only ever failed on this single image. I just don’t have the time or inclination to debug this in a program that I would have to learn to in fact debug it with any efficiency. If this isn’t failing for anyone else, I’ll just chalk it up as an anomaly for now.

If I run into this again and can’t find a way around, maybe I’ll take up the challenge to debug it. Either way, thanks for the tips!

@afre

  1. This is nothing more than a cover scan. The entire point of the post is that this particular image seems to be the problem. It has never failed for me on another image. I posted it full size as I thought the size might have something to do with the issue. I don’t think there is a copyright issue here, but I’ll pull the image.

  2. There are no options other than the preview type. I only knew of a single “Descreen” filter, so I thought it would be obvious as to the filter I was referring to. I am aware of the Fourier Transform filters, but they don’t refer to “Descreen” AFAIK.

  1. Yeah, since it’s in testing and not color, I didn’t think there would be any confusion. Sorry for not supplying the screenshot earlier.

I seen cases where filters fail on images. If it just a fluke, and can’t be reliably reproduced, then it’s just that. I had one bug report for my Rotate by Torus Map filter, and a user reported that it always crash with said image.

What happens if you change a single pixel very slightly?

So if I change any pixels in the image, it still responds the same.

It does appear that the image size was indeed the issue though. The original image is 6780x3000. After scaling it to a few sizes, it works just fine on the smaller images. Even at 6500x2876. it works fine.

It’s hard to believe my machine is the issue. It’s around a month old and is adequately equipped IMO.

  • Intel Core i7 9700K 3.6GHz Eight Core 12MB 95W
  • 2 x Samsung DDR4-2666 32GB
  • EVGA GeForce RTX 2070 SUPER XC 8GB
  • Samsung 970 Pro 1TB M.2 SSD

If no one else experienced the same trouble before I pulled the image, then maybe it really is my machine. If I run into it again, I guess I’ll just manually use FFT instead, or just resize first.

If image size is why some filters do not work, then how can we resolve this? I’m wondering if the image size would fail with the earlier filter I pointed to. See if it does.

The clearer the problem is presented the better. I have GIMP 2.10 and G’MIC 2.9.0.

Before (100% zoom)

After (100% zoom)

Remarks

Issues The filter doesn’t remove the patterning (in the preview and after applying). It not only alters the colour (after applying only), it also generates patches of discoloration (after applying only).

Experiment I wrote a simple filter to see if I could remove the pattern. Looks like the pattern is too indistinct to attenuate properly. The softness could be due to camera shake or image compression.

Seems to work just fine.

Okay, it doesn’t seem like image size is the issue. @afre seem to experience the bug. I will defer to @afre.

Actually, I performed it on the whole image. On a crop, the colour is fine but the pattern is still there.

More interestingly, in CLI, the discoloration is different. I have only tried it once for each case (GUI full, GUI crop and CLI full) and with my quickly written filter. Have already spent too much time on this. Please verify whether the discoloration is consistent in each case and across cases.

PS Anyway, this could be due to a number of reasons: the filter’s age, FFT shenanigans, parallel processing, plugin vs gimp vs CLI speak, CPU/GPU drivers, compatibility issues, you name it… The good thing is that I can reproduce the bug to a certain extent.

The CLI discolorization is probably due to normalization. But, I could be assuming here.

Not sure if this is directed at me or not, but I also agree that I’ve spent too much time on this. It’s not a show stopper for me so I’m moving on. I guess if the devs want it fixed, it will get fixed since it’s reproducible.

Appreciate all the help. I ended up learning some things about gmic, and learning is always a good thing.

You could try 'Iain Remove Pattern'to remove the pattern

1 Like

Iain Remove Pattern is much faster too. The default parameters work. Softens the image quite a bit, so you may need to tweak them and sharpen afterward.


Back to fx_pahlsson_descreen, if I use RGB channels instead of CMYK, the splotchy discoloration goes away. However, as I said, the pattern remains. Would help if the filter had parameters to tweak. :roll_eyes:

@afre Here’s a better view of the pattern. I’ve normalised it, it looks like it might be from another part of the image entirely.