Actually, I have no idea what you’re trying to do here. @Joan_Rake1 knows what meshgrid is, but I don’t.
Does G’MIC have a function like this?
foo( num,2,5 ) = num^2^2^2^2^2
For fill function - I used this “nexp(a,b,c)=(for(n=0,n<c,n++,a^b));”
Look everyone, my very first macro and use of eval~!
fooip_: skip ${1=2},${2=2},${3=5}
eval fooip(x,y,z)=x^(y*z);fooip($1,$2,$3) e[] " "${}
gmic fooip_ 2,2,5
1024
@afre @Iain How would you go by pixel sorting every pixel from top left pixel to bottom right pixel? I would like to pixel sort luminosity of every pixel in an arbitrary width and height in that order.
The only solution I can think of is to make a iterative algorithm which use bubble sorting.
I thought there were already a few commands and functions that do pixel sorting. In addition, fill
already goes from pixel to pixel in a loop starting from 0,0,0,0
.
pixelsort command gives me the option to go from left to right and top to bottom, but however combining both does not order every pixels from top left to bottom left. I was thinking of something like this.
1 0 5 4
2 2 3 4
8 9 1 3
to
0 1 1 2
2 3 3 4
4 5 8 9
I just learned how to do this
This should sort the pixels of a single channel image
Width={w}
-unroll x
-sort x
-split x,$width
-append y
LOL, I was planning to give breadcrumb hints…
Thanks, I did modified it a bit as sort x
was giving me a error in Krita.
ww={w}
to_gray
unroll x
pixelsort +,x
s x,$ww
a y
This is the error. 1 layer.
Let’s say I want to extrude pixel in 3d form at a specific distance, then at the bottom, it is a point in space with the point being a color and everything inbetween is a gradient from 4 or 2 channel image to the point color, then finally render the orthographic output. How would I do this?
EDIT - I realized I could use a droste code. I’ll look at those.
EDIT - Nah, I couldn’t do it. I do picture it in my head, just can’t convert into math, and then code it in.
EDIT - This is the closest I could find to the solution, it’s still not the best one though - Shaped gradient - my first plugin - Plugin Developer's Central - paint.net Forum
There’s also Light Rays, but I don’t know how to make it go backward after looking at the source, and use it to convert it into shaped gradient.
I want to do 3x3
but cannot. There must be a space before x
, otherwise x
disappears. E.g.
foo_by_:
t=3 e[^-1] "Filter with a "$t"x "$t" filter" # Filter with a 3 filter
Does \
works? @afre
No, that would introduce a special character. This works though:
foo_by_:
t=3 e[^-1] "Filter with a "$t{`"120"`}$t" filter" # Filter with a 3x3 filter
Thats because $t"x "
is actually equivalent to $tx" "
and variable $tx
is not defined.
In that case, use ${t}"x"${t}
instead.
@David_Tschumperle @Reptorian I started a conversation about MATLAB / Octave having array indexing in posts 474-479 (when I focused on conditionals). Here is another example where I find it expedient.
I have been making PDFs and CDFs, and wanted to check if I got it right by matching the output, which is a long column of values in Octave and a displayed image in G’MIC. Eyeballing the values is kind of annoying, esp. the super tall column of Octave. To simplify the task, I could do find(pdf>0)
and pdf(pdf>0)
to find the indexes and values, respectively, that are greater than 0; or whatever else I would like to query.
octave:8> find(pdf>0)
ans =
85
92
104
106
108
113
114
116
117
124
125
126
128
octave:9> pdf(pdf>0)
ans =
0.066667
0.066667
0.066667
0.066667
0.133333
0.133333
0.066667
0.066667
0.066667
0.066667
0.066667
0.066667
0.066667
I am unsure whether I could do something similar in G’MIC.
Also, I wonder if there is a way to view the data in console. The default behavior is to truncate it to data = (0,0,0,0,0,0,0,0,0,0,0,0,(...),0,0,0,0,0,0,0,0,0,0,0,0).
. I feel the interpreters lack what the other has in this respect. They might have the feature but I am not aware of it or it isn’t simple to do.
Without knowing what that command does in depth, I can’t help you. Would dar_insert help?
It is more of a commentary on how we can query data and / or generate new arrays or vectors from it. The example in my last post is a 256,1,1,1
image where most values are 0
, so to compare the two without saving it in one environment and inputting it in another is to find values that >0
.
In Octave
, I can do find(pdf>0)
to find the indexes and pdf(pdf>0)
to find the corresponding values. In gmic
, I display
the image and query by zooming to the various locations to find the values. It would be nice, if I could do something similar in gmic
: being able to output values in the console or querying certain subsets of the data using conditionals. The latter is possible but not convenient to do; i.e. a short statement like find(pdf>0)
already does so much or my previous example from many posts ago
octave:1> N=[0,1,2]
N = 0 1 2
octave:2> med=median(N(N!=0))
med = 1.5000
Of course, the array indexing of Octave / MATLAB stretched to its full potential is a world of confusion to read. I don’t like that one bit! But simple uses are very handy and powerful.
Something like this may help :
#@cli extract : "condition",_output_type={ 0=xyzc-coordinates | 1=xyz-coordinates | 2=scalar-values | 3=vector-values }
#@cli : Extract a list of coordinates or values from selected image, where
#@cli : specified mathematical condition holds.
#@cli : For N coordinates matching, result is a 1xNx1x4 image.
#@cli : Default values: 'output_type=2'.
#@cli : sp lena +extract_coords "norm(I)>128",3
extract : check "isin(${2=2},0,1,2,3)"
v - s0,s1,s2,s3=xyzc-coordinates,xyz-coordinates,scalar-values,vector-values
v + e[^-1] "Extract "$s$2" from image$? verifying condition '$1'." v -
repeat $! l[$>]
1,32,1,{arg(1+$2,4,3,1,s)}
str=">"${-math_lib}"($1)?("
if $2==0 str.="dar_insert(#-1,[x,y,z,c]));i"
elif $2==1 str.="dar_insert(#-1,[x,y,z]));I"
elif $2==2 str.="dar_insert(#-1,i));i"
else str.="dar_insert(#-1,I));I"
fi
eval.. $str";end(resize(#-1,1,dar_size(#-1),1,s,0))" k.
endl done v +
It is a command that extract a list of coordinates or values from an image, where specified condition holds.
Then, for instance, you can use it like this :
$ gmic 100,100,1,3,'a=y/h;oma=1-a;a*[255,0,0]+oma*[0,255,0]' 100%,100% circle. 50%,50%,30%,1,1 mul +extract[0] "I!=[0\,0\,0]",1 +extract[0] "I!=[0\,0\,0]",3
Here, I first create an image of a circle with a color gradient in it (left image).
Then I use extract
to extract the list of all coordinates where the color is different from black (middle image). And I re-use extract
to get the corresponding colors for these coordinates.
Thanks! Saves me the trouble of figuring out the math interpreter and other syntax. Will see how it applies to the 2 cases later.
PS I don’t know what +extract[0] "I!=[0\,0\,0]",1
does. I only see a gradient only (rotated)
and +extract[0] "I!=[0\,0\,0]",3
is exactly the same as the input image. a y
below (rotated).
But what is your input image ?