Forums > MaxMSP

Selecting Large Areas (Max and Jitter Question)

April 28, 2008 | 2:11 pm

Hiya ive been trying to figure out something for ages and im completely stumped to find an easier solution.

Basically i have an image running through jit.qt.movie.
I want it so when i click a particular part of the image something happens. This bit i can do.
The problem is because the area in the picture is so big im trying to find away so that when i click any of it something happens not just on one exact spot.

For example if i had a picture of a duck in a pond. I wouldnt just want to click on one point on that duck. The whole duck should do the same thing.

At the moment i can get past this by putting every single possible location in the select box
for instance select 389218 389219 (389 x value 218 y value)
However this is going to take for ever. Is there anyway of tell maxs the lowest point and then the highest point so it can calculate the numbers in-between?

Thanks



Eli
April 28, 2008 | 3:20 pm

ubutton?


April 28, 2008 | 3:26 pm

you should be able to use an if/then statement to check your x y value and do whatever you need it to do if it’s within the space. In this example the if/then object will bang if the first value is between 0 and 4 and the second value is between 8 and 15. This will work if you have a square area you’d like to define. A ubutton will do the same thing, however if you’re changing your pictures you can simply change the variables of the if/then object.

If you need to be more precise, check out the cv.jit objects for blob recognition. I haven’t personally used the objects all that much to be able to be more specific but it seems like it’d be the right direction.

{
"patcher" : {
"fileversion" : 1,
"rect" : [ 80.0, 69.0, 640.0, 506.0 ],
"bglocked" : 0,
"defrect" : [ 80.0, 69.0, 640.0, 506.0 ],
"openrect" : [ 0.0, 0.0, 0.0, 0.0 ],
"openinpresentation" : 0,
"default_fontsize" : 12.0,
"default_fontface" : 0,
"default_fontname" : "Arial",
"gridonopen" : 0,
"gridsize" : [ 15.0, 15.0 ],
"gridsnaponopen" : 0,
"toolbarvisible" : 1,
"boxanimatetime" : 200,
"imprint" : 0,
"metadata" : [ ],
"boxes" : [ {
"box" : {
"maxclass" : "comment",
"text" : "example coordinates ->",
"numoutlets" : 0,
"patching_rect" : [ 29.0, 31.0, 135.0, 20.0 ],
"id" : "obj-12",
"fontname" : "Arial",
"fontsize" : 12.0,
"numinlets" : 1
}

}
, {
"box" : {
"maxclass" : "message",
"text" : "2 12",
"numoutlets" : 1,
"patching_rect" : [ 212.0, 32.0, 34.0, 18.0 ],
"id" : "obj-11",
"outlettype" : [ "" ],
"fontname" : "Arial",
"fontsize" : 12.0,
"presentation_rect" : [ 281.0, 53.0, 0.0, 0.0 ],
"numinlets" : 2
}

}
, {
"box" : {
"maxclass" : "message",
"text" : "12 14",
"numoutlets" : 1,
"patching_rect" : [ 168.0, 32.0, 41.0, 18.0 ],
"id" : "obj-10",
"outlettype" : [ "" ],
"fontname" : "Arial",
"fontsize" : 12.0,
"numinlets" : 2
}

}
, {
"box" : {
"maxclass" : "newobj",
"text" : "unpack 0 0",
"numoutlets" : 2,
"patching_rect" : [ 168.0, 71.0, 69.0, 20.0 ],
"id" : "obj-9",
"outlettype" : [ "int", "int" ],
"fontname" : "Arial",
"fontsize" : 12.0,
"numinlets" : 1
}

}
, {
"box" : {
"maxclass" : "button",
"numoutlets" : 1,
"patching_rect" : [ 168.0, 226.0, 20.0, 20.0 ],
"id" : "obj-8",
"outlettype" : [ "bang" ],
"numinlets" : 1
}

}
, {
"box" : {
"maxclass" : "number",
"numoutlets" : 2,
"patching_rect" : [ 168.0, 118.0, 50.0, 20.0 ],
"id" : "obj-6",
"outlettype" : [ "int", "bang" ],
"fontname" : "Arial",
"fontsize" : 12.0,
"numinlets" : 1
}

}
, {
"box" : {
"maxclass" : "number",
"numoutlets" : 2,
"patching_rect" : [ 446.0, 115.0, 50.0, 20.0 ],
"id" : "obj-5",
"outlettype" : [ "int", "bang" ],
"fontname" : "Arial",
"fontsize" : 12.0,
"numinlets" : 1
}

}
, {
"box" : {
"maxclass" : "newobj",
"text" : "if $i1 > 0 && $i1 < 4 && $i2 > 8 && $i2 < 15 then bang",
"numoutlets" : 1,
"patching_rect" : [ 168.0, 147.0, 297.0, 20.0 ],
"id" : "obj-1",
"outlettype" : [ "" ],
"fontname" : "Arial",
"fontsize" : 12.0,
"numinlets" : 2
}

}
],
"lines" : [ {
"patchline" : {
"source" : [ "obj-11", 0 ],
"destination" : [ "obj-9", 0 ],
"hidden" : 0,
"midpoints" : [ ]
}

}
, {
"patchline" : {
"source" : [ "obj-10", 0 ],
"destination" : [ "obj-9", 0 ],
"hidden" : 0,
"midpoints" : [ ]
}

}
, {
"patchline" : {
"source" : [ "obj-9", 0 ],
"destination" : [ "obj-6", 0 ],
"hidden" : 0,
"midpoints" : [ ]
}

}
, {
"patchline" : {
"source" : [ "obj-9", 1 ],
"destination" : [ "obj-5", 0 ],
"hidden" : 0,
"midpoints" : [ 227.5, 97.0, 455.5, 97.0 ]
}

}
, {
"patchline" : {
"source" : [ "obj-1", 0 ],
"destination" : [ "obj-8", 0 ],
"hidden" : 0,
"midpoints" : [ ]
}

}
, {
"patchline" : {
"source" : [ "obj-6", 0 ],
"destination" : [ "obj-1", 0 ],
"hidden" : 0,
"midpoints" : [ ]
}

}
, {
"patchline" : {
"source" : [ "obj-5", 0 ],
"destination" : [ "obj-1", 1 ],
"hidden" : 0,
"midpoints" : [ ]
}

}
]
}

}


http://www.bryanteoh.com
http://www.icelu.net

http://www.ksod.net


April 28, 2008 | 5:20 pm

you should familiarize yourself with comparison operators.
the question you are asking is how to detect when numbers are inside a
specific range.
[split] will give you one answer, as will [>=] , [< =] etc.

incidentally you could use my [multisplit external if you wanted to
check several ranges at once.

see inlined patch

hth

/*j

———-begin_max5_patcher———-
1479.3oc4assjahCD8YOeET7PdxwktwEs0lsp86HUpsv1LdXGL3BjyN6lJ+6
qPBLfGvVFaZHIyC1fsLb5SeT2sZz7smVXuN8svbaqey5yVKV7smVrP8QEevh
xyWXuO3sMwA4pgYeHZiHONZaXl8R8WuNUHR2+0f3igEi.iPkeQTxWixiVGGt
90cIaUeW42HRObZ7Ui9PfXyKQI69qrvMBMhb3qPKsntEuJurmdy5KU+lrv7v
DQfHJMo40O439nj3PgBxjxOLKZ2KhNfobvoGEmO5HEfsSW+2ejgpL07MAwgu
ljtt4MqIHZ.drquBvt7dgu91J92Cg5ehjwD1K0uY8khw78mdp3kkF5bjlx5Z
GyyoIhjf8pKt8elEEDexksaSZbZl9thV46J+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HlW8VmowLq1j7boqn5EOzeSQ6ygNeaVJ9T8Z8swaTaw
SlWyUMU71k2TVsbYpgZKKA67svshgK9719w7ziYaptZUcnxp9NtMLWDkbhj+
bcaNsv06JunsaCSZJw2Gs8PpDbkfnGUkwXhZJlPfgIlIPxGTH4YBj3fBoyXf
twDEVZ5LJXVfIpI7TQGNfTgiL.SEaItaASt5GNLUWcm9DtSu4ctIrhMAq2PT
KLiqe5spxukEjVcx8BVrADKrySMBREOW0a2WSnD8J7pOCBgoZeT2IZwFnL8I
mNABko5+bjaArURSMZwkayfG.b4FfVJrgqM.QdfinqFWDTDYRFMBrbjqIIzf
MIK1jjrD5LjmfMY.laJOggkmtVX.BFVemQIMmf4cWkmPvhIjo7Db5ISVQIF1
PAXSvDEVINlYToVvtVISJnB17uF0fBJvQBLoLEJc9kAlxleY6nNyuHlT24W1
NJrUhS4l11D.yrXjuC1J5n34GlNqaV836.dkcF0U26IVf7ju+z+S5YE5J
———–end_max5_patcher———–


April 28, 2008 | 7:27 pm

wow thanks for all your speedy replies.

I got it working using a if statement that bryanteoh suggested and it works like a dream.

:D

but thanks for the other suggestions i feel rather more educated in max/msp now


Viewing 5 posts - 1 through 5 (of 5 total)