+ Reply to Thread
Results 1 to 19 of 19

Quantities from image

  1. #1
    Registered User
    Join Date
    11-22-2010
    Location
    ny
    MS-Off Ver
    Excel 2007
    Posts
    5

    Quantities from image

    Hey there.

    I'm new to Excel programming and wanted to get an idea if this is possible:

    I want to load up an image in excel, count a certain number of items on the image through mouse clicks, and then have the final tally show up in a cell.

    I have some programming experience (VB, Javascript), so how difficult would it be to execute this? Thanks.

  2. #2
    Forum Guru
    Join Date
    08-26-2007
    Location
    London
    Posts
    4,606

    Re: Quantities from image

    Do you mean you want to count up specific areas of the picture, or what?

  3. #3
    Registered User
    Join Date
    11-22-2010
    Location
    ny
    MS-Off Ver
    Excel 2007
    Posts
    5

    Re: Quantities from image

    Yea. For example there are different labels on the image. So I want a total count of labels A, then a total count of labels B etc.

    And then have the final counts of all the labels in separate cells.

  4. #4
    Forum Guru
    Join Date
    08-26-2007
    Location
    London
    Posts
    4,606

    Re: Quantities from image

    Can you post a sample because I'm not sure I follow?

  5. #5
    Registered User
    Join Date
    11-22-2010
    Location
    ny
    MS-Off Ver
    Excel 2007
    Posts
    5

    Re: Quantities from image

    Sure thing.

    So in the attachement, I would have a final count of 2 for the E and F labels (red and green), 1 for the C label (blue), and 3 for the yellow labels.

    I would mark each label as I go through the image.
    Attached Images Attached Images

  6. #6
    Forum Guru
    Join Date
    08-26-2007
    Location
    London
    Posts
    4,606

    Re: Quantities from image

    But is that just a flat picture (so to speak)? As opposed to the coloured labels being distinct pictures? You might be able to do it based on cursor location but I imagine it would be fiendishly difficult and I'm not sure Excel is the best vehicle for this anyway.

  7. #7
    Registered User
    Join Date
    11-22-2010
    Location
    ny
    MS-Off Ver
    Excel 2007
    Posts
    5

    Re: Quantities from image

    It would be a flat image and the colors would be marked as you count on the image through clicks.

    And yea, I had a feeling Excel might not be the best way to go. Although I had seen someone do this in Excel before, hence my question.

  8. #8
    Forum Guru
    Join Date
    08-26-2007
    Location
    London
    Posts
    4,606

    Re: Quantities from image

    Well I'm not saying it can't be done. It would take me more time than I am willing to invest I'm afraid, but some of the guys here have magic powers...

  9. #9
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,419

    Re: Quantities from image

    You could use a ActiveX image control to contain the image and capture clicks.

    Please Login or Register  to view this content.
    This will simply incerment the active cell with each click. It will fail if the contents of the cell are such that adding 1 is not sensible.

    Another way would be to use a userform and image. But I guess the hardest part is knowing what information is being gathered when a click happens. By that I mean you need to somehow tell the code that current clicks are related the "F" marks or "E" marks.
    Cheers
    Andy
    www.andypope.info

  10. #10
    Forum Guru
    Join Date
    08-26-2007
    Location
    London
    Posts
    4,606

    Re: Quantities from image

    By that I mean you need to somehow tell the code that current clicks are related the "F" marks or "E" marks.
    Could you use the MouseOver event for that, if the x and y were known?

  11. #11
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,419

    Re: Quantities from image

    If you know the xy locations then you know how many so the task becomes redundent.

    But technically yes. Although a simply mouse over is likely to pickup extra counts as the action is not a positive one. Clicking is a more positive action.

  12. #12
    Forum Guru
    Join Date
    08-26-2007
    Location
    London
    Posts
    4,606

    Re: Quantities from image

    Actually I was thinking you could check the x and y when the mouse was clicked, but I see now that probably not possible.

  13. #13
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,419

    Re: Quantities from image

    The mouseover event will report a x and y value but you still have to somehow tell the code what to do with that information.

  14. #14
    Forum Guru
    Join Date
    08-26-2007
    Location
    London
    Posts
    4,606

    Re: Quantities from image

    Well you could just add one to a counter couldn't you, but as you say moving a mouse far from ideal as one could do it accidentally.

  15. #15
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,419

    Re: Quantities from image

    Image the image was 10x10 with a mark at 5x5

    The mouse move event would fire many times before, with values such as 1x1 2x2 3x3 4x4, before reaching the valid point of 5x5. How does the code know not to increment for the preceeding 4 positions and only at 5x5?

  16. #16
    Forum Guru
    Join Date
    08-26-2007
    Location
    London
    Posts
    4,606

    Re: Quantities from image

    See my post 12, I was thinking that you could check x and y before adding to the counter, but after checking I see there is no parameter in the mouseclick event.

  17. #17
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,419

    Re: Quantities from image

    The MouseUp or MouseDown events will give you the x and y value.

  18. #18
    Forum Guru
    Join Date
    08-26-2007
    Location
    London
    Posts
    4,606

    Re: Quantities from image

    I suppose you could have something activated by mouse over in the appropriate place which asks if you want to add one. Anyway, sure the OP has long since left to look for something else.

  19. #19
    Registered User
    Join Date
    11-22-2010
    Location
    ny
    MS-Off Ver
    Excel 2007
    Posts
    5

    Re: Quantities from image

    Actually I'm saving this for future reference now that I'm learning VBA.

    Thanks for the help guys

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1