Math Is Fun Forum

  Discussion about math, puzzles, games and fun.   Useful symbols: ÷ × ½ √ ∞ ≠ ≤ ≥ ≈ ⇒ ± ∈ Δ θ ∴ ∑ ∫ • π ƒ -¹ ² ³ °

You are not logged in.

#26 2014-01-26 23:25:34

Agnishom
Real Member
From: Riemann Sphere
Registered: 2011-01-29
Posts: 24,974
Website

Re: Mathematica - Counting Balls

Who is the Original poster you're reffering to?


'And fun? If maths is fun, then getting a tooth extraction is fun. A viral infection is fun. Rabies shots are fun.'
'God exists because Mathematics is consistent, and the devil exists because we cannot prove it'
I'm not crazy, my mother had me tested.

Offline

#27 2014-01-26 23:28:15

bobbym
bumpkin
From: Bumpkinland
Registered: 2009-04-12
Posts: 109,606

Re: Mathematica - Counting Balls

That is a good question. He has glasses, a beard and short hair.


In mathematics, you don't understand things. You just get used to them.
If it ain't broke, fix it until it is.
Always satisfy the Prime Directive of getting the right answer above all else.

Offline

#28 2014-01-27 00:03:32

Agnishom
Real Member
From: Riemann Sphere
Registered: 2011-01-29
Posts: 24,974
Website

Re: Mathematica - Counting Balls

Anonymnistefy?


'And fun? If maths is fun, then getting a tooth extraction is fun. A viral infection is fun. Rabies shots are fun.'
'God exists because Mathematics is consistent, and the devil exists because we cannot prove it'
I'm not crazy, my mother had me tested.

Offline

#29 2014-01-27 02:05:24

phrontister
Real Member
From: The Land of Tomorrow
Registered: 2009-07-12
Posts: 4,810

Re: Mathematica - Counting Balls

bobbym wrote:

He has glasses, a beard and short hair.

Like this?


"The good news about computers is that they do what you tell them to do. The bad news is that they do what you tell them to do." - Ted Nelson

Offline

#30 2014-01-27 02:47:44

bobbym
bumpkin
From: Bumpkinland
Registered: 2009-04-12
Posts: 109,606

Re: Mathematica - Counting Balls

I was talking about this fellow.

95904.gif

Anyway, did anyone try those commands on the OP's picture?


In mathematics, you don't understand things. You just get used to them.
If it ain't broke, fix it until it is.
Always satisfy the Prime Directive of getting the right answer above all else.

Offline

#31 2014-01-27 03:05:15

Agnishom
Real Member
From: Riemann Sphere
Registered: 2011-01-29
Posts: 24,974
Website

Re: Mathematica - Counting Balls

Yes, I did whatever was on that help page replacing their picture with mine and it did not work


'And fun? If maths is fun, then getting a tooth extraction is fun. A viral infection is fun. Rabies shots are fun.'
'God exists because Mathematics is consistent, and the devil exists because we cannot prove it'
I'm not crazy, my mother had me tested.

Offline

#32 2014-01-27 03:08:15

bobbym
bumpkin
From: Bumpkinland
Registered: 2009-04-12
Posts: 109,606

Re: Mathematica - Counting Balls

I did it too but I do not understand enough about image processing and its commands to alter them for your problem. I am working on it though.


In mathematics, you don't understand things. You just get used to them.
If it ain't broke, fix it until it is.
Always satisfy the Prime Directive of getting the right answer above all else.

Offline

#33 2014-01-27 17:15:54

phrontister
Real Member
From: The Land of Tomorrow
Registered: 2009-07-12
Posts: 4,810

Re: Mathematica - Counting Balls

I also tried it - M's 'Analyze Segmented Cells in an Image' ("ASCI") program - and failed.

I found something on the net and used it on Agnishom's image - see my first image. Pasting my image into ASCI gave the result "0". sad

The code is from here.

Just paste the cropped version of Agnishom's image from my post #35 into M immediately before the semicolon in the first line.

I haven't worked out how to include the white balls in the colour change operation, though, which is something I wanted to do and then somehow count all same-coloured balls, but maybe that's not critical.

The program from the second image numbered the cells that it found (including some that overlap), but the count numbering is wrong (see Edit below) and not all overlapping cells are identified. ASCI didn't count any overlapping cells, nor any that just touched (eg, #77 in the second image). And ASCI found #69 but not #38. Also, ASCI only found 31 cells compared with this program's 65.

ASCI can probably be tweaked to find touching/overlapping balls...and in Agnishom's image the overlapping is only slight.

The code is from here.

Just paste the cropped version of Agnishom's image from my post #35 into M immediately before the semicolon in the first line.

Where to go from here with that info or how to gauge if it's at all useful for us... dizzy

Edit: Adding the line "measures // Length" to the end of the program for the second image gives the actual count: 65. Maybe the missing numbers refer to marks (eg, blotches, incomplete cells) that the code deemed to be invalid but still included them in the numbering (invisibly).

Last edited by phrontister (2014-01-28 01:06:37)


"The good news about computers is that they do what you tell them to do. The bad news is that they do what you tell them to do." - Ted Nelson

Offline

#34 2014-01-27 22:49:22

bobbym
bumpkin
From: Bumpkinland
Registered: 2009-04-12
Posts: 109,606

Re: Mathematica - Counting Balls

Hi phrontister;

Link please.


In mathematics, you don't understand things. You just get used to them.
If it ain't broke, fix it until it is.
Always satisfy the Prime Directive of getting the right answer above all else.

Offline

#35 2014-01-27 23:22:32

phrontister
Real Member
From: The Land of Tomorrow
Registered: 2009-07-12
Posts: 4,810

Re: Mathematica - Counting Balls

Here's another coding option I found on the net. This one, unlike others I've tried, at least recognizes (I think) some, but not all, of the balls.

It doesn't draw circles around the balls properly and the numbering is strange, but it found 199 objects (balls?)...and it drew about that number of circles (I didn't count them).

The code is from StackExchange, here.

StackExchange had .81 where I've got .7 in line 2. I played around with several options, and that was close to the best.

You'll need to paste Agnishom's image (just use my cropped one below) immediately before the semicolon in the first line.

The last image shows the result I got in M by pasting the StackExchange image into their code (with their .81 in the second line instead of my .7).


"The good news about computers is that they do what you tell them to do. The bad news is that they do what you tell them to do." - Ted Nelson

Offline

#36 2014-01-27 23:29:21

bobbym
bumpkin
From: Bumpkinland
Registered: 2009-04-12
Posts: 109,606

Re: Mathematica - Counting Balls

Hi;

Okay, I am looking at it now.


In mathematics, you don't understand things. You just get used to them.
If it ain't broke, fix it until it is.
Always satisfy the Prime Directive of getting the right answer above all else.

Offline

#37 2014-01-27 23:31:28

phrontister
Real Member
From: The Land of Tomorrow
Registered: 2009-07-12
Posts: 4,810

Re: Mathematica - Counting Balls

Hi Bobby,

I included two links in post #33 just now.


"The good news about computers is that they do what you tell them to do. The bad news is that they do what you tell them to do." - Ted Nelson

Offline

#38 2014-01-27 23:38:36

bobbym
bumpkin
From: Bumpkinland
Registered: 2009-04-12
Posts: 109,606

Re: Mathematica - Counting Balls

I do not remember but what was the actual count of the balls?


In mathematics, you don't understand things. You just get used to them.
If it ain't broke, fix it until it is.
Always satisfy the Prime Directive of getting the right answer above all else.

Offline

#39 2014-01-27 23:58:35

phrontister
Real Member
From: The Land of Tomorrow
Registered: 2009-07-12
Posts: 4,810

Re: Mathematica - Counting Balls

485


"The good news about computers is that they do what you tell them to do. The bad news is that they do what you tell them to do." - Ted Nelson

Offline

#40 2014-01-28 00:02:18

bobbym
bumpkin
From: Bumpkinland
Registered: 2009-04-12
Posts: 109,606

Re: Mathematica - Counting Balls

Because of the black background it looks like the programs are counting the spaces rather than the balls.


In mathematics, you don't understand things. You just get used to them.
If it ain't broke, fix it until it is.
Always satisfy the Prime Directive of getting the right answer above all else.

Offline

#41 2014-01-28 00:11:14

phrontister
Real Member
From: The Land of Tomorrow
Registered: 2009-07-12
Posts: 4,810

Re: Mathematica - Counting Balls

But not with the green background in the third image of post #35...

...and the rings around those shapes are correctly positioned.


"The good news about computers is that they do what you tell them to do. The bad news is that they do what you tell them to do." - Ted Nelson

Offline

#42 2014-01-28 00:16:13

bobbym
bumpkin
From: Bumpkinland
Registered: 2009-04-12
Posts: 109,606

Re: Mathematica - Counting Balls

But not when you apply it to Agnishom's picture.


In mathematics, you don't understand things. You just get used to them.
If it ain't broke, fix it until it is.
Always satisfy the Prime Directive of getting the right answer above all else.

Offline

#43 2014-01-28 00:36:21

phrontister
Real Member
From: The Land of Tomorrow
Registered: 2009-07-12
Posts: 4,810

Re: Mathematica - Counting Balls

I changed the background colour of the third image in post #35 and got these strange results. Hmm...


"The good news about computers is that they do what you tell them to do. The bad news is that they do what you tell them to do." - Ted Nelson

Offline

#44 2014-01-28 00:41:47

bobbym
bumpkin
From: Bumpkinland
Registered: 2009-04-12
Posts: 109,606

Re: Mathematica - Counting Balls

Hi;

Very confusing and doubly so because I have no idea what any of the commands are doing.

See you later, need some sleep.


In mathematics, you don't understand things. You just get used to them.
If it ain't broke, fix it until it is.
Always satisfy the Prime Directive of getting the right answer above all else.

Offline

#45 2014-01-28 01:02:24

phrontister
Real Member
From: The Land of Tomorrow
Registered: 2009-07-12
Posts: 4,810

Re: Mathematica - Counting Balls

Ditto!

It's not making any sense to me either, and I think it would be a loooong, steeeep, uphill road to make this work...if that's even possible. What might have helped is a background of constant shade and of a colour quite different from the balls.

I'm at a total loss and would need to dive into M and graphics analysis/processing at the deep end before I could be of any real help, and of course that's not on.

I've probably spent enough time on this, and I'm soooo far out of my depth here that it's probably about time I called it quits...unless you can revive my flagging interest.

Catch you later, and sleep well (I'm about to tuck in too). You never know...in the a.m. I might wake up rejuvenated, rearing to have another crack at it. Ha!


"The good news about computers is that they do what you tell them to do. The bad news is that they do what you tell them to do." - Ted Nelson

Offline

#46 2014-01-28 04:38:14

bobbym
bumpkin
From: Bumpkinland
Registered: 2009-04-12
Posts: 109,606

Re: Mathematica - Counting Balls

Hi;

I will do a little reading on it and see what turns up. See you tomorrow.


In mathematics, you don't understand things. You just get used to them.
If it ain't broke, fix it until it is.
Always satisfy the Prime Directive of getting the right answer above all else.

Offline

#47 2014-01-28 05:07:50

Agnishom
Real Member
From: Riemann Sphere
Registered: 2011-01-29
Posts: 24,974
Website

Re: Mathematica - Counting Balls

I have an idea how it can be done, but I do not know enough programming to do it.

1. Use something like what is called a magic wand in Image editing software. It selects all the pixels which it thinks is of the same color as a given pixel to a certain thresold.
2. Count the number of discontinuous pieces of the unselected region. This can be done by scanning the whole image pixel by pixel and incrementing the counter by one whenever the current pixel is outside a selection and a immediate neighbouring pixel is selected.

Alternate to 2: Divide the total unselected area by the average area of 1 ball


'And fun? If maths is fun, then getting a tooth extraction is fun. A viral infection is fun. Rabies shots are fun.'
'God exists because Mathematics is consistent, and the devil exists because we cannot prove it'
I'm not crazy, my mother had me tested.

Offline

#48 2014-01-28 07:09:43

bobbym
bumpkin
From: Bumpkinland
Registered: 2009-04-12
Posts: 109,606

Re: Mathematica - Counting Balls

but I do not know enough programming to do it.

That is how I am trying but I know little about image processing so the commands are difficult to understand so how can the program be done?


In mathematics, you don't understand things. You just get used to them.
If it ain't broke, fix it until it is.
Always satisfy the Prime Directive of getting the right answer above all else.

Offline

Board footer

Powered by FluxBB