# Where does these rows come from?

Hi, I am having a problem with this command I’m working on. See the bottom image to see what I mean. The black image contains value of 1,0 only. That’s why it is a black image.

``````# \$ gmic i lena1.png i 5050.png channels. 0 rep_form_pixel_generate_results_a 0,0,50,50#
rep_form_pixel_generate_results_a:

{w#0},{h#0},1,{s#0},i0#1*i#0
{w#0},{h#0},1,{s#0},(1-i0#1)*i#0
repeat s#0
ci={\$>}
repeat 2 sh.. \$ci done
sh[0] \$ci

f. "
begin(
const ww=abs(\$3);
const hh=abs(\$4);
const wwhh=ww*hh;
const length=floor(w/ww);
avg_a=vectorlength(0);
avg_b=vectorlength(0);
avg_c=avg(crop(#1,0,0,ww,hh));
w_avg=wwhh*avg_c;
iw_avg=wwhh-w_avg;
);
if(!x&&!(y%hh),
for(v=0,v<length,v++,
avg_a[v]=sum(crop(#-3,v*ww,y,ww,hh))/w_avg;
avg_b[v]=sum(crop(#-2,v*ww,y,ww,hh))/iw_avg;
);
);
lerp(avg_a[floor(x/ww)],avg_b[floor(x/ww)],i#1);
"
rm[-3--1]
done
rm[-2,-1]
``````

I meant to point out that the black image isn’t entirely black as in 0,0,0. The focus should be about those weird black rows that shows up when executing the command using those 2 images. I do not have any idea where they came from.

You mean the left side of second image? Thought the stripes were by design. Cool effect.

Yes. That’s the thing, there’s no indication of where they come from.

Try starting your expression with character `>` to explicitly disable multi-threaded evaluation.
Variables defined in `begin()` are shared by multiple threads when they are running in parallel, and this may have an effect for you here.

1 Like

That fixes it. Thanks!

Usually, the expression parser tries to determine automatically if multi-threading must be disabled, but in case of complex expressions, it sometimes fails.
When writing a math expression in G’MIC, it’s a good practice to think about the fact it might be evaluated in parallel by default, and explicitly disable multi-threading if the expression cannot be evaluated this way.