Discussion:
Comparing pictures
Jean-Luc Arnaud
2018-03-16 16:42:56 UTC
Permalink
Hi all,

I'm used to drawing icons in Listbox cells.

I need to compare these icons with pictures, in order to determine what
action should fire when clicked.

I know coordinates of each icon in the cell.

1) Is the RGBSurface and Pixel comparison a good way?

2) How to get an RGBSurface of a cell area in the CellClick event? I
can't figure out how to get a Graphics object of the area and then a
RGBSurface.

All suggestion welcome, including MBS plugins use.

TIA for your help.
--
Jean-Luc Arnaud
donJ
2018-03-16 21:59:04 UTC
Permalink
Post by Jean-Luc Arnaud
Hi all,
I'm used to drawing icons in Listbox cells.
I need to compare these icons with pictures, in order to determine
what action should fire when clicked.
I know coordinates of each icon in the cell.
1) Is the RGBSurface and Pixel comparison a good way?
2) How to get an RGBSurface of a cell area in the CellClick event? I
can't figure out how to get a Graphics object of the area and then a
RGBSurface.
All suggestion welcome, including MBS plugins use.
TIA for your help.
Hi Jean-Luc,
As I recall, RGBSurface is pretty slow. As you draw the icon, could you
put an identifier in a cell tag or an array and check that instead of
reading the icon directly? Just a thought.

Don Jungk
Jean-Luc Arnaud
2018-03-19 09:44:44 UTC
Permalink
Thanks for replying, Don.
As you draw the icon, could you put an identifier in a cell tag or an
array and check that instead of reading the icon directly? Just a
thought.
Yes, it's currently the only way I can figure out. Unfortunately, all
tags (Cell or Row) of my listbox are used, so, it only remains the array...

Or maybe an additional and hidden column? What do you think about that?

Jean-Luc Arnaud
Post by Jean-Luc Arnaud
Hi all,
I'm used to drawing icons in Listbox cells.
I need to compare these icons with pictures, in order to determine
what action should fire when clicked.
I know coordinates of each icon in the cell.
1) Is the RGBSurface and Pixel comparison a good way?
2) How to get an RGBSurface of a cell area in the CellClick event? I
can't figure out how to get a Graphics object of the area and then a
RGBSurface.
All suggestion welcome, including MBS plugins use.
TIA for your help.
Hi Jean-Luc,
As I recall, RGBSurface is pretty slow. As you draw the icon, could
you put an identifier in a cell tag or an array and check that instead
of reading the icon directly? Just a thought.
Don Jungk
g***@bitbazar.com
2018-03-19 09:50:55 UTC
Permalink
Ji Jean-luc,

but the celltags are of variant type,
so you can store everything there


you could simply define a class, with the parameters you need,
and set the celltag to an instance of that class.
so you can store multiple different values in a single cell tag

hope it helps,

 Giulio

Giulio Mastrosanti
BitBazar srl
06 39737052 / 06 39725787
Post by Jean-Luc Arnaud
Thanks for replying, Don.
As you draw the icon, could you put an identifier in a cell tag or an
array and check that instead of reading the icon directly? Just a
thought.
Yes, it's currently the only way I can figure out. Unfortunately, all
tags (Cell or Row) of my listbox are used, so, it only remains the array...
Or maybe an additional and hidden column? What do you think about that?
Jean-Luc Arnaud
Post by Jean-Luc Arnaud
Hi all,
I'm used to drawing icons in Listbox cells.
I need to compare these icons with pictures, in order to determine
what action should fire when clicked.
I know coordinates of each icon in the cell.
1) Is the RGBSurface and Pixel comparison a good way?
2) How to get an RGBSurface of a cell area in the CellClick event? I
can't figure out how to get a Graphics object of the area and then a
RGBSurface.
All suggestion welcome, including MBS plugins use.
TIA for your help.
Hi Jean-Luc,
As I recall, RGBSurface is pretty slow. As you draw the icon, could
you put an identifier in a cell tag or an array and check that instead
of reading the icon directly? Just a thought.
Don Jungk
Jean-Luc Arnaud
2018-03-19 14:37:50 UTC
Permalink
Thanks, Giulio.

Yes, this is helpful! I know since some days that a Variant may content
a dictionary! And a lot of another things.

I should have thought to that...

Grazie mille!

Jean-Luc Arnaud
Post by g***@bitbazar.com
Ji Jean-luc,
but the celltags are of variant type,
so you can store everything there

you could simply define a class, with the parameters you need,
and set the celltag to an instance of that class.
so you can store multiple different values in a single cell tag
hope it helps,
 Giulio
Giulio Mastrosanti
*BitBazar srl*
06 39737052 / 06 39725787
On 19 mar 2018, 10:45 +0100, Jean-Luc Arnaud
Post by Jean-Luc Arnaud
Thanks for replying, Don.
As you draw the icon, could you put an identifier in a cell tag or an
array and check that instead of reading the icon directly? Just a
thought.
Yes, it's currently the only way I can figure out. Unfortunately, all
tags (Cell or Row) of my listbox are used, so, it only remains the array...
Or maybe an additional and hidden column? What do you think about that?
Jean-Luc Arnaud
Post by Jean-Luc Arnaud
Hi all,
I'm used to drawing icons in Listbox cells.
I need to compare these icons with pictures, in order to determine
what action should fire when clicked.
I know coordinates of each icon in the cell.
1) Is the RGBSurface and Pixel comparison a good way?
2) How to get an RGBSurface of a cell area in the CellClick event? I
can't figure out how to get a Graphics object of the area and then a
RGBSurface.
All suggestion welcome, including MBS plugins use.
TIA for your help.
Hi Jean-Luc,
As I recall, RGBSurface is pretty slow. As you draw the icon, could
you put an identifier in a cell tag or an array and check that instead
of reading the icon directly? Just a thought.
Don Jungk
Eduardo Gutierrez de O
2018-03-19 16:14:18 UTC
Permalink
A variant can even contain a dictionary of variants :)

Another option is to subclass your listbox and add those additional properties to the cells, rows, columns.

Eduo
Post by Jean-Luc Arnaud
Thanks, Giulio.
Yes, this is helpful! I know since some days that a Variant may content a dictionary! And a lot of another things.
I should have thought to that...
Grazie mille!
Jean-Luc Arnaud
Post by g***@bitbazar.com
Ji Jean-luc,
but the celltags are of variant type,
so you can store everything there

you could simply define a class, with the parameters you need,
and set the celltag to an instance of that class.
so you can store multiple different values in a single cell tag
hope it helps,
 Giulio
Giulio Mastrosanti
BitBazar srl
06 39737052 / 06 39725787
Post by Jean-Luc Arnaud
Thanks for replying, Don.
As you draw the icon, could you put an identifier in a cell tag or an
array and check that instead of reading the icon directly? Just a
thought.
Yes, it's currently the only way I can figure out. Unfortunately, all
tags (Cell or Row) of my listbox are used, so, it only remains the array...
Or maybe an additional and hidden column? What do you think about that?
Jean-Luc Arnaud
Post by Jean-Luc Arnaud
Hi all,
I'm used to drawing icons in Listbox cells.
I need to compare these icons with pictures, in order to determine
what action should fire when clicked.
I know coordinates of each icon in the cell.
1) Is the RGBSurface and Pixel comparison a good way?
2) How to get an RGBSurface of a cell area in the CellClick event? I
can't figure out how to get a Graphics object of the area and then a
RGBSurface.
All suggestion welcome, including MBS plugins use.
TIA for your help.
Hi Jean-Luc,
As I recall, RGBSurface is pretty slow. As you draw the icon, could
you put an identifier in a cell tag or an array and check that instead
of reading the icon directly? Just a thought.
Don Jungk
Eduardo Gutierrez de O
2018-03-17 11:39:02 UTC
Permalink
Hi, Jean-Luc

This is not what you're asking, but I'm intrigued.

When you say you're comparing pictures you mean actually comparing the images themselves? If so, are you using some sort of p-hash or the images are identical?

Eduo
Post by Jean-Luc Arnaud
Hi all,
I'm used to drawing icons in Listbox cells.
I need to compare these icons with pictures, in order to determine what action should fire when clicked.
I know coordinates of each icon in the cell.
1) Is the RGBSurface and Pixel comparison a good way?
2) How to get an RGBSurface of a cell area in the CellClick event? I can't figure out how to get a Graphics object of the area and then a RGBSurface.
All suggestion welcome, including MBS plugins use.
TIA for your help.
--
Jean-Luc Arnaud
Jean-Luc Arnaud
2018-03-19 09:39:24 UTC
Permalink
Post by Eduardo Gutierrez de O
you mean actually comparing the images themselves?
Yes, indeed. But they are only icons, 32x32 or 16x16 pixels, so
comparing pixel to pixel should be fast.

Jean-Luc Arnaud
Post by Eduardo Gutierrez de O
Hi, Jean-Luc
This is not what you're asking, but I'm intrigued.
When you say you're comparing pictures you mean actually comparing the images themselves? If so, are you using some sort of p-hash or the images are identical?
Eduo
Post by Jean-Luc Arnaud
Hi all,
I'm used to drawing icons in Listbox cells.
I need to compare these icons with pictures, in order to determine what action should fire when clicked.
I know coordinates of each icon in the cell.
1) Is the RGBSurface and Pixel comparison a good way?
2) How to get an RGBSurface of a cell area in the CellClick event? I can't figure out how to get a Graphics object of the area and then a RGBSurface.
All suggestion welcome, including MBS plugins use.
TIA for your help.
--
Jean-Luc Arnaud
Eduardo Gutierrez de O
2018-03-19 16:18:22 UTC
Permalink
Understood.

I wasn't sure what you meant by "comparing". If they need to be identical it's not a problem but I thought it might mean finding the closest similarity.

For the latter I've used perceptual hashes (p-hashes) in the past with good results. They're also acceptably fast (I do ther comparison in images of several megapixels originally). They allow you to get a "score" of similarity and a confidence value, which helps taking decisions. The hash is text, so it's not memory intensive either.

Eduo
Post by Eduardo Gutierrez de O
you mean actually comparing the images themselves?
Yes, indeed. But they are only icons, 32x32 or 16x16 pixels, so comparing pixel to pixel should be fast.
Jean-Luc Arnaud
Post by Eduardo Gutierrez de O
Hi, Jean-Luc
This is not what you're asking, but I'm intrigued.
When you say you're comparing pictures you mean actually comparing the images themselves? If so, are you using some sort of p-hash or the images are identical?
Eduo
Post by Jean-Luc Arnaud
Hi all,
I'm used to drawing icons in Listbox cells.
I need to compare these icons with pictures, in order to determine what action should fire when clicked.
I know coordinates of each icon in the cell.
1) Is the RGBSurface and Pixel comparison a good way?
2) How to get an RGBSurface of a cell area in the CellClick event? I can't figure out how to get a Graphics object of the area and then a RGBSurface.
All suggestion welcome, including MBS plugins use.
TIA for your help.
--
Jean-Luc Arnaud
Jean-Luc Arnaud
2018-03-20 12:27:20 UTC
Permalink
Post by Eduardo Gutierrez de O
If they need to be identical it's not a problem
Yes, this is a problem, because I don't know how to get graphic area and
picture from the content of a listbox cell!

But it doesn't matter, I think the best way is to add a hidden column or
subclass the ListBox class, as previously suggested.

Thanks a lot.

Jean-Luc Arnaud
Post by Eduardo Gutierrez de O
Understood.
I wasn't sure what you meant by "comparing". If they need to be identical it's not a problem but I thought it might mean finding the closest similarity.
For the latter I've used perceptual hashes (p-hashes) in the past with good results. They're also acceptably fast (I do ther comparison in images of several megapixels originally). They allow you to get a "score" of similarity and a confidence value, which helps taking decisions. The hash is text, so it's not memory intensive either.
Eduo
Post by Eduardo Gutierrez de O
you mean actually comparing the images themselves?
Yes, indeed. But they are only icons, 32x32 or 16x16 pixels, so comparing pixel to pixel should be fast.
Jean-Luc Arnaud
Post by Eduardo Gutierrez de O
Hi, Jean-Luc
This is not what you're asking, but I'm intrigued.
When you say you're comparing pictures you mean actually comparing the images themselves? If so, are you using some sort of p-hash or the images are identical?
Eduo
Post by Jean-Luc Arnaud
Hi all,
I'm used to drawing icons in Listbox cells.
I need to compare these icons with pictures, in order to determine what action should fire when clicked.
I know coordinates of each icon in the cell.
1) Is the RGBSurface and Pixel comparison a good way?
2) How to get an RGBSurface of a cell area in the CellClick event? I can't figure out how to get a Graphics object of the area and then a RGBSurface.
All suggestion welcome, including MBS plugins use.
TIA for your help.
--
Jean-Luc Arnaud
Continue reading on narkive:
Loading...