colour sorting of larger matrices

Feb 11, 2012 at 7:26pm

colour sorting of larger matrices

hi,

I’m trying to sort all the pixels in a video matrix per colour (with different sorting criterias, for ex. sorting HSL – starting with lowest luminance etc…)

i then want to put alle the sortet pixels back together in a new matrix.

it already works with small matrices (100×100).

i first jit.unpack then jit.spill every plane complete (a list of 10000 luminance values for ex.)

i then sort this list with zl sort and use the outcoming indices with zl lookup to pair the correct hsl values again. this ensures that the original hsl groups stay togehter.

then i jit.fill them back to a new matrix.

this works quite well by now – but there might still be a list lentgh limitation for zl in max 6 – about 32.000 i think?

any ideas how i could resize my patch to sort colours at higer resolutions?

will post my patch after cleanup ;)

greets
thomas

#61724
Feb 11, 2012 at 10:13pm

here’s the patch…

{
“boxes” : [ {
"box" : {
"maxclass" : "message",
"text" : "10",
"patching_rect" : [ 595.0, 77.5, 32.5, 18.0 ],
“id” : “obj-11″,
“fontname” : “Arial”,
“numoutlets” : 1,
“outlettype” : [ "" ],
“fontsize” : 12.0,
“numinlets” : 2
}

}
, {
“box” : {
“maxclass” : “newobj”,
“text” : “loadbang”,
“patching_rect” : [ 595.0, 52.0, 60.0, 20.0 ],
“id” : “obj-6″,
“fontname” : “Arial”,
“numoutlets” : 1,
“outlettype” : [ "bang" ],
“fontsize” : 12.0,
“numinlets” : 1
}

}
, {
“box” : {
“maxclass” : “jit.pwindow”,
“patching_rect” : [ 162.25, 783.0, 391.0, 277.0 ],
“id” : “obj-85″,
“numoutlets” : 2,
“outlettype” : [ "", "" ],
“numinlets” : 1
}

}
, {
“box” : {
“maxclass” : “message”,
“text” : “clear”,
“patching_rect” : [ 131.5, 651.0, 37.0, 18.0 ],
“id” : “obj-8″,
“fontname” : “Arial”,
“numoutlets” : 1,
“outlettype” : [ "" ],
“fontsize” : 12.0,
“numinlets” : 2
}

}
, {
“box” : {
“maxclass” : “umenu”,
“patching_rect” : [ 579.5, 679.0, 91.0, 20.0 ],
“id” : “obj-144″,
“fontname” : “Arial”,
“numoutlets” : 3,
“parameter_enable” : 0,
“outlettype” : [ "int", "", "" ],
“fontsize” : 11.595187,
“items” : [ "RGB", ",", "RetinalCone", ",", "XYZ", ",", "UVW", ",", "uvY", ",", "xyY", ",", "U*V*W*", ",", "S0W*", ",", "L*HoC*", ",", "YIQ", ",", "YUV", ",", "RGBcie", ",", "RGBsmpte", ",", "HSV", ",", "HLS", ",", "IHS", ",", "L*a*b*", ",", "L*u*v*", ",", "CMY", ",", "CMYK", ",", "I1I2I3" ],
“numinlets” : 1
}

}
, {
“box” : {
“maxclass” : “umenu”,
“patching_rect” : [ 579.5, 592.0, 91.0, 20.0 ],
“id” : “obj-145″,
“fontname” : “Arial”,
“numoutlets” : 3,
“parameter_enable” : 0,
“outlettype” : [ "int", "", "" ],
“fontsize” : 11.595187,
“items” : [ "RGB", ",", "RetinalCone", ",", "XYZ", ",", "UVW", ",", "uvY", ",", "xyY", ",", "U*V*W*", ",", "S0W*", ",", "L*HoC*", ",", "YIQ", ",", "YUV", ",", "RGBcie", ",", "RGBsmpte", ",", "HSV", ",", "HLS", ",", "IHS", ",", "L*a*b*", ",", "L*u*v*", ",", "CMY", ",", "CMYK", ",", "I1I2I3" ],
“numinlets” : 1
}

}
, {
“box” : {
“maxclass” : “attrui”,
“attr” : “output”,
“patching_rect” : [ 615.5, 710.0, 226.0, 21.0 ],
“id” : “obj-146″,
“fontname” : “Arial”,
“numoutlets” : 1,
“outlettype” : [ "" ],
“fontsize” : 13.0,
“numinlets” : 1
}

}
, {
“box” : {
“maxclass” : “attrui”,
“attr” : “input”,
“patching_rect” : [ 615.5, 623.0, 226.0, 21.0 ],
“id” : “obj-147″,
“fontname” : “Arial”,
“numoutlets” : 1,
“outlettype” : [ "" ],
“fontsize” : 13.0,
“numinlets” : 1,
“attrfilter” : [ "input" ]
}

}
, {
“box” : {
“maxclass” : “newobj”,
“text” : “jit.colorspace”,
“patching_rect” : [ 162.25, 732.0, 81.0, 20.0 ],
“id” : “obj-148″,
“fontname” : “Arial”,
“numoutlets” : 2,
“outlettype” : [ "jit_matrix", "" ],
“fontsize” : 12.0,
“numinlets” : 1
}

}
, {
“box” : {
“maxclass” : “umenu”,
“patching_rect” : [ 429.75, 106.5, 91.0, 20.0 ],
“id” : “obj-137″,
“fontname” : “Arial”,
“numoutlets” : 3,
“parameter_enable” : 0,
“outlettype” : [ "int", "", "" ],
“fontsize” : 11.595187,
“items” : [ "RGB", ",", "RetinalCone", ",", "XYZ", ",", "UVW", ",", "uvY", ",", "xyY", ",", "U*V*W*", ",", "S0W*", ",", "L*HoC*", ",", "YIQ", ",", "YUV", ",", "RGBcie", ",", "RGBsmpte", ",", "HSV", ",", "HLS", ",", "IHS", ",", "L*a*b*", ",", "L*u*v*", ",", "CMY", ",", "CMYK", ",", "I1I2I3" ],
“numinlets” : 1
}

}
, {
“box” : {
“maxclass” : “umenu”,
“patching_rect” : [ 315.75, 21.0, 91.0, 20.0 ],
“id” : “obj-138″,
“fontname” : “Arial”,
“numoutlets” : 3,
“parameter_enable” : 0,
“outlettype” : [ "int", "", "" ],
“fontsize” : 11.595187,
“items” : [ "RGB", ",", "RetinalCone", ",", "XYZ", ",", "UVW", ",", "uvY", ",", "xyY", ",", "U*V*W*", ",", "S0W*", ",", "L*HoC*", ",", "YIQ", ",", "YUV", ",", "RGBcie", ",", "RGBsmpte", ",", "HSV", ",", "HLS", ",", "IHS", ",", "L*a*b*", ",", "L*u*v*", ",", "CMY", ",", "CMYK", ",", "I1I2I3" ],
“numinlets” : 1
}

}
, {
“box” : {
“maxclass” : “attrui”,
“attr” : “output”,
“patching_rect” : [ 465.75, 140.0, 226.0, 21.0 ],
“id” : “obj-139″,
“fontname” : “Arial”,
“numoutlets” : 1,
“outlettype” : [ "" ],
“fontsize” : 13.0,
“numinlets” : 1
}

}
, {
“box” : {
“maxclass” : “attrui”,
“attr” : “input”,
“patching_rect” : [ 351.75, 52.0, 226.0, 21.0 ],
“id” : “obj-140″,
“fontname” : “Arial”,
“numoutlets” : 1,
“outlettype” : [ "" ],
“fontsize” : 13.0,
“numinlets” : 1,
“attrfilter” : [ "input" ]
}

}
, {
“box” : {
“maxclass” : “newobj”,
“text” : “jit.colorspace”,
“patching_rect” : [ 257.25, 169.5, 81.0, 20.0 ],
“id” : “obj-141″,
“fontname” : “Arial”,
“numoutlets” : 2,
“outlettype” : [ "jit_matrix", "" ],
“fontsize” : 12.0,
“numinlets” : 1
}

}
, {
“box” : {
“maxclass” : “newobj”,
“text” : “zl 32400 lookup”,
“patching_rect” : [ 428.0, 590.0, 95.0, 20.0 ],
“id” : “obj-7″,
“fontname” : “Arial”,
“numoutlets” : 2,
“outlettype” : [ "", "" ],
“fontsize” : 12.0,
“numinlets” : 2
}

}
, {
“box” : {
“maxclass” : “newobj”,
“text” : “zl 32400 lookup”,
“patching_rect” : [ 296.0, 590.0, 95.0, 20.0 ],
“id” : “obj-4″,
“fontname” : “Arial”,
“numoutlets” : 2,
“outlettype” : [ "", "" ],
“fontsize” : 12.0,
“numinlets” : 2
}

}
, {
“box” : {
“maxclass” : “newobj”,
“text” : “jit.spill @listlength 10000″,
“patching_rect” : [ 428.0, 396.0, 143.0, 20.0 ],
“id” : “obj-102″,
“fontname” : “Arial”,
“numoutlets” : 2,
“outlettype” : [ "", "" ],
“fontsize” : 12.0,
“numinlets” : 1
}

}
, {
“box” : {
“maxclass” : “newobj”,
“text” : “jit.spill @listlength 10000″,
“patching_rect” : [ 272.0, 396.0, 143.0, 20.0 ],
“id” : “obj-101″,
“fontname” : “Arial”,
“numoutlets” : 2,
“outlettype” : [ "", "" ],
“fontsize” : 12.0,
“numinlets” : 1
}

}
, {
“box” : {
“maxclass” : “newobj”,
“text” : “jit.fill sum @plane 3″,
“patching_rect” : [ 428.0, 623.0, 115.0, 20.0 ],
“id” : “obj-84″,
“fontname” : “Arial”,
“numoutlets” : 2,
“outlettype” : [ "", "" ],
“fontsize” : 12.0,
“numinlets” : 1
}

}
, {
“box” : {
“maxclass” : “newobj”,
“text” : “jit.fill sum @plane 2″,
“patching_rect” : [ 296.0, 623.0, 115.0, 20.0 ],
“id” : “obj-83″,
“fontname” : “Arial”,
“numoutlets” : 2,
“outlettype” : [ "", "" ],
“fontsize” : 12.0,
“numinlets” : 1
}

}
, {
“box” : {
“maxclass” : “newobj”,
“text” : “jit.fill sum @plane 1″,
“patching_rect” : [ 175.0, 623.0, 115.0, 20.0 ],
“id” : “obj-67″,
“fontname” : “Arial”,
“numoutlets” : 2,
“outlettype” : [ "", "" ],
“fontsize” : 12.0,
“numinlets” : 1
}

}
, {
“box” : {
“maxclass” : “newobj”,
“text” : “zl 32400 sort”,
“patching_rect” : [ 175.0, 590.0, 79.0, 20.0 ],
“id” : “obj-40″,
“fontname” : “Arial”,
“numoutlets” : 2,
“outlettype” : [ "", "" ],
“fontsize” : 12.0,
“numinlets” : 2
}

}
, {
“box” : {
“maxclass” : “newobj”,
“text” : “jit.spill @listlength 10000″,
“patching_rect” : [ 100.25, 396.0, 143.0, 20.0 ],
“id” : “obj-32″,
“fontname” : “Arial”,
“numoutlets” : 2,
“outlettype” : [ "", "" ],
“fontsize” : 12.0,
“numinlets” : 1
}

}
, {
“box” : {
“maxclass” : “newobj”,
“text” : “jit.matrix sum 4 char 180 180″,
“patching_rect” : [ 175.0, 679.0, 165.0, 20.0 ],
“id” : “obj-30″,
“fontname” : “Arial”,
“numoutlets” : 2,
“outlettype” : [ "jit_matrix", "" ],
“fontsize” : 12.0,
“numinlets” : 1
}

}
, {
“box” : {
“maxclass” : “newobj”,
“text” : “jit.unpack”,
“patching_rect” : [ 257.25, 199.0, 146.0, 20.0 ],
“id” : “obj-13″,
“fontname” : “Arial”,
“numoutlets” : 5,
“outlettype” : [ "jit_matrix", "jit_matrix", "jit_matrix", "jit_matrix", "" ],
“fontsize” : 12.0,
“numinlets” : 1
}

}
, {
“box” : {
“maxclass” : “toggle”,
“patching_rect” : [ 182.0, 22.0, 20.0, 20.0 ],
“id” : “obj-5″,
“numoutlets” : 1,
“parameter_enable” : 0,
“outlettype” : [ "int" ],
“numinlets” : 1
}

}
, {
“box” : {
“maxclass” : “newobj”,
“text” : “qmetro 50″,
“patching_rect” : [ 182.0, 52.0, 65.0, 20.0 ],
“id” : “obj-3″,
“fontname” : “Arial”,
“numoutlets” : 1,
“outlettype” : [ "bang" ],
“fontsize” : 12.0,
“numinlets” : 2
}

}
, {
“box” : {
“maxclass” : “newobj”,
“text” : “jit.qt.movie 180 180″,
“patching_rect” : [ 182.0, 90.0, 115.0, 20.0 ],
“id” : “obj-1″,
“fontname” : “Arial”,
“numoutlets” : 2,
“outlettype” : [ "jit_matrix", "" ],
“fontsize” : 12.0,
“numinlets” : 1
}

}
, {
“box” : {
“maxclass” : “message”,
“text” : “read $1″,
“patching_rect” : [ 261.0, 52.0, 50.0, 18.0 ],
“id” : “obj-2″,
“fontname” : “Arial”,
“numoutlets” : 1,
“outlettype” : [ "" ],
“fontsize” : 12.0,
“numinlets” : 2
}

}
, {
“box” : {
“maxclass” : “attrui”,
“attr” : “listlength”,
“patching_rect” : [ 21.25, 301.0, 174.0, 20.0 ],
“id” : “obj-9″,
“fontname” : “Arial”,
“numoutlets” : 1,
“outlettype” : [ "" ],
“fontsize” : 12.0,
“numinlets” : 1
}

}
, {
“box” : {
“maxclass” : “attrui”,
“attr” : “zlmaxsize”,
“patching_rect” : [ 13.25, 477.0, 169.0, 20.0 ],
“id” : “obj-15″,
“fontname” : “Arial”,
“numoutlets” : 1,
“outlettype” : [ "" ],
“fontsize” : 12.0,
“numinlets” : 1
}

}
],
“lines” : [ {
"patchline" : {
"source" : [ "obj-9", 0 ],
“destination” : [ "obj-32", 0 ],
“hidden” : 0,
“disabled” : 0
}

}
, {
“patchline” : {
“source” : [ "obj-9", 0 ],
“destination” : [ "obj-102", 0 ],
“hidden” : 0,
“disabled” : 0
}

}
, {
“patchline” : {
“source” : [ "obj-9", 0 ],
“destination” : [ "obj-101", 0 ],
“hidden” : 0,
“disabled” : 0
}

}
, {
“patchline” : {
“source” : [ "obj-84", 0 ],
“destination” : [ "obj-30", 0 ],
“hidden” : 0,
“disabled” : 0
}

}
, {
“patchline” : {
“source” : [ "obj-83", 0 ],
“destination” : [ "obj-30", 0 ],
“hidden” : 0,
“disabled” : 0
}

}
, {
“patchline” : {
“source” : [ "obj-8", 0 ],
“destination” : [ "obj-30", 0 ],
“hidden” : 0,
“disabled” : 0
}

}
, {
“patchline” : {
“source” : [ "obj-7", 0 ],
“destination” : [ "obj-84", 0 ],
“hidden” : 0,
“disabled” : 0
}

}
, {
“patchline” : {
“source” : [ "obj-67", 0 ],
“destination” : [ "obj-30", 0 ],
“hidden” : 0,
“disabled” : 0
}

}
, {
“patchline” : {
“source” : [ "obj-6", 0 ],
“destination” : [ "obj-11", 0 ],
“hidden” : 0,
“disabled” : 0
}

}
, {
“patchline” : {
“source” : [ "obj-5", 0 ],
“destination” : [ "obj-3", 0 ],
“hidden” : 0,
“disabled” : 0
}

}
, {
“patchline” : {
“source” : [ "obj-40", 1 ],
“destination” : [ "obj-7", 0 ],
“hidden” : 0,
“midpoints” : [ 244.5, 619.0, 341.0, 619.0, 341.0, 580.0, 437.5, 580.0 ],
“disabled” : 0
}

}
, {
“patchline” : {
“source” : [ "obj-40", 0 ],
“destination” : [ "obj-67", 0 ],
“hidden” : 0,
“disabled” : 0
}

}
, {
“patchline” : {
“source” : [ "obj-40", 1 ],
“destination” : [ "obj-4", 0 ],
“hidden” : 0,
“midpoints” : [ 244.5, 619.0, 275.0, 619.0, 275.0, 580.0, 305.5, 580.0 ],
“disabled” : 0
}

}
, {
“patchline” : {
“source” : [ "obj-4", 0 ],
“destination” : [ "obj-83", 0 ],
“hidden” : 0,
“disabled” : 0
}

}
, {
“patchline” : {
“source” : [ "obj-32", 0 ],
“destination” : [ "obj-40", 0 ],
“hidden” : 0,
“disabled” : 0
}

}
, {
“patchline” : {
“source” : [ "obj-30", 0 ],
“destination” : [ "obj-148", 0 ],
“hidden” : 0,
“disabled” : 0
}

}
, {
“patchline” : {
“source” : [ "obj-3", 0 ],
“destination” : [ "obj-1", 0 ],
“hidden” : 0,
“disabled” : 0
}

}
, {
“patchline” : {
“source” : [ "obj-2", 0 ],
“destination” : [ "obj-1", 0 ],
“hidden” : 0,
“disabled” : 0
}

}
, {
“patchline” : {
“source” : [ "obj-15", 0 ],
“destination” : [ "obj-7", 0 ],
“hidden” : 0,
“disabled” : 0
}

}
, {
“patchline” : {
“source” : [ "obj-15", 0 ],
“destination” : [ "obj-40", 0 ],
“hidden” : 0,
“disabled” : 0
}

}
, {
“patchline” : {
“source” : [ "obj-15", 0 ],
“destination” : [ "obj-4", 0 ],
“hidden” : 0,
“disabled” : 0
}

}
, {
“patchline” : {
“source” : [ "obj-148", 0 ],
“destination” : [ "obj-85", 0 ],
“hidden” : 0,
“disabled” : 0
}

}
, {
“patchline” : {
“source” : [ "obj-147", 0 ],
“destination” : [ "obj-148", 0 ],
“hidden” : 0,
“disabled” : 0
}

}
, {
“patchline” : {
“source” : [ "obj-146", 0 ],
“destination” : [ "obj-148", 0 ],
“hidden” : 0,
“disabled” : 0
}

}
, {
“patchline” : {
“source” : [ "obj-145", 1 ],
“destination” : [ "obj-147", 0 ],
“hidden” : 0,
“disabled” : 0
}

}
, {
“patchline” : {
“source” : [ "obj-144", 1 ],
“destination” : [ "obj-146", 0 ],
“hidden” : 0,
“disabled” : 0
}

}
, {
“patchline” : {
“source” : [ "obj-141", 0 ],
“destination” : [ "obj-13", 0 ],
“hidden” : 0,
“disabled” : 0
}

}
, {
“patchline” : {
“source” : [ "obj-140", 0 ],
“destination” : [ "obj-141", 0 ],
“hidden” : 0,
“disabled” : 0
}

}
, {
“patchline” : {
“source” : [ "obj-139", 0 ],
“destination” : [ "obj-141", 0 ],
“hidden” : 0,
“disabled” : 0
}

}
, {
“patchline” : {
“source” : [ "obj-138", 1 ],
“destination” : [ "obj-140", 0 ],
“hidden” : 0,
“disabled” : 0
}

}
, {
“patchline” : {
“source” : [ "obj-137", 0 ],
“destination” : [ "obj-145", 0 ],
“hidden” : 0,
“midpoints” : [ 439.25, 376.75, 589.0, 376.75 ],
“disabled” : 0
}

}
, {
“patchline” : {
“source” : [ "obj-137", 1 ],
“destination” : [ "obj-139", 0 ],
“hidden” : 0,
“disabled” : 0
}

}
, {
“patchline” : {
“source” : [ "obj-13", 1 ],
“destination” : [ "obj-32", 0 ],
“hidden” : 0,
“disabled” : 0
}

}
, {
“patchline” : {
“source” : [ "obj-13", 3 ],
“destination” : [ "obj-102", 0 ],
“hidden” : 0,
“disabled” : 0
}

}
, {
“patchline” : {
“source” : [ "obj-13", 2 ],
“destination” : [ "obj-101", 0 ],
“hidden” : 0,
“disabled” : 0
}

}
, {
“patchline” : {
“source” : [ "obj-11", 0 ],
“destination” : [ "obj-137", 0 ],
“hidden” : 0,
“disabled” : 0
}

}
, {
“patchline” : {
“source” : [ "obj-102", 0 ],
“destination” : [ "obj-7", 1 ],
“hidden” : 0,
“disabled” : 0
}

}
, {
“patchline” : {
“source” : [ "obj-101", 0 ],
“destination” : [ "obj-4", 1 ],
“hidden” : 0,
“disabled” : 0
}

}
, {
“patchline” : {
“source” : [ "obj-1", 0 ],
“destination” : [ "obj-141", 0 ],
“hidden” : 0,
“disabled” : 0
}

}
]
}

#222863

You must be logged in to reply to this topic.