Author Topic: Category Counts Script  (Read 2638 times)

PaulS

  • Full Member
  • **
  • Posts: 142
Category Counts Script
« on: February 16, 2015, 12:57:00 AM »
This is a simple script that counts the number of times an image is assigned to a particular category and its children category and assigns that count to an attribute.  This can be useful if you want to find images with a specific group of people but not any others.

For example, to find images with Mom and Dad only, you might build a category with "Subject.People.Mom" AND "Subject.People.Dad".  But this will also have images that contain other people in addition to Mom and Dad.  After running this script, you can apply an attribute filter with Count.People = 2 to show images containing only Mom and Dad.

The attribute set and attributes must be created prior to running the script.  The default categories and attributes can be changed by modifying the variable definitions in the script. The script will count assigned categories including child categories, but excluded alias, formula, and data-driven categories.

The script needs to be rerun on any image whose categorization is changed in a manner that affects the count.

It was inspired by khodadad's "Grouped People" script in IMatch 3.

[attachment deleted by admin]

sinus

  • Global Moderator
  • *****
  • Posts: 4342
  • IMatch-User since 2001 (IMatch 3.6)
Re: Category Counts Script
« Reply #1 on: February 16, 2015, 09:02:44 AM »
Hey Paul
Thanks for sharing this script. I looked into the code: clear code and nice commented!
Hmmm, if you call this "a simple script" I wonder, how a sophisticated script would look like from you!  ;D

Thanks, well done and BTW, a pity, that Khodadad has not more the time (or he has another reasion) to share this forum.
Best wishes from Switzerland! :-)
Markus

Richard

  • Guest
Re: Category Counts Script
« Reply #2 on: February 16, 2015, 02:18:24 PM »
Khodadad's inactivity makes me worry and I miss his posts.

Ferdinand

  • 100 years since I was shot and a war was started
  • Global Moderator
  • *****
  • Posts: 1670
Re: Category Counts Script
« Reply #3 on: February 16, 2015, 10:17:58 PM »
He was here about a year ago, although I haven't checked precisely when.  He dropped in to see how things are, and helped me with a script.  Then he left again.  I agree it's a pity, but people move on.  When you consider who was in that original alpha testers group there are very few of us left.  We don't see Carl M, Chris L or Ben W any more either.  But I agree that khodadad is a major loss, because of all the support he provided.

PaulS

  • Full Member
  • **
  • Posts: 142
Re: Category Counts Script
« Reply #4 on: February 17, 2015, 04:03:16 AM »
+1

Ferdinand

  • 100 years since I was shot and a war was started
  • Global Moderator
  • *****
  • Posts: 1670
Re: Category Counts Script
« Reply #5 on: February 17, 2015, 11:24:52 AM »
Actually it was just over two years ago, on the other forum.  Seems he signed up here but hasn't been back for 6 months.  Come back khodadad, we miss you!!