« first day (2820 days earlier)      last day (402 days later) » 

11:50 AM
@flawr Especially if you happen to be shorting the banking sector :)
 
 
1 hour later…
12:57 PM
@Dev-iL haha:)
 
1:26 PM
@Dev-iL :-)
 
 
2 hours later…
3:52 PM
posted on March 21, 2023 by Steve Eddins

For some shapes, especially ones with a small number of pixels, a commonly-used method for computing circularity often results in a value which is biased high, and which can be greater than 1. In... read more >>

 
4:22 PM
@Feeds @CrisLuengo probably relevant to you ^
 
4:40 PM
@AndrasDeak--СлаваУкраїні Thanks. Nice to see him referencing my blog. :)
 
But the link mistakenly includes the comma:/ (which leads to a 404 page at Cris' blog!)
 
@flawr :(
 
@CrisLuengo You could add an url-rewrite direcitve to your .htaccess file to ignore trailing nonsense :)
 
In DIPlib, instead of correcting for the bias in the circularity method, we correct for the bias in the perimeter. When using the Vossepeol and Smeulders method they reference, the length estimate is unbiased, but it is the length of a curve through the center of the pixels at the perimeter of the object, not of a curve at the perimeter of the object. You can see that this curve is offset by 1 pixel.
Assuming a circle, this means that the perimeter is underestimated by pi. DIPlib adds pi to the estimated perimeter to get its unbiased perimeter estimate.
@flawr too much of too much effort
 
5:19 PM
@CrisLuengo ah, I didn't notice that, sorry. Just skimmed it.
 
5:29 PM
I just saw that you can use MATLAB Online for up to 20 hours a month for free.
 
 
4 hours later…
9:13 PM
NumPy is so freaking frustrating...
>>> img = np.ones(10, np.uint16)
>>> img *= 100   # still uint16
>>> img * 100
array([10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000,
       10000], dtype=uint16)
>>> img * 1000
array([34464, 34464, 34464, 34464, 34464, 34464, 34464, 34464, 34464,
       34464], dtype=uint16)
>>> img * 10000
array([16960, 16960, 16960, 16960, 16960, 16960, 16960, 16960, 16960,
       16960], dtype=uint16)
>>> img * 100000
array([10000000, 10000000, 10000000, 10000000, 10000000, 10000000,
       10000000, 10000000, 10000000, 10000000], dtype=uint32)
MATLAB does this right IMO:
>> img = ones(1,10,'uint16') * 100
img =
  1×10 uint16 row vector
   100   100   100   100   100   100   100   100   100   100
>> img * 100
ans =
  1×10 uint16 row vector
   10000   10000   10000   10000   10000   10000   10000   10000   10000   10000
>> img * 1000
ans =
  1×10 uint16 row vector
   65535   65535   65535   65535   65535   65535   65535   65535   65535   65535
>> img * 10000
ans =
  1×10 uint16 row vector
   65535   65535   65535   65535   65535   65535   65535   65535   65535   65535
 
@CrisLuengo note that python ints are bigints, unlike matlab ints which are doubles or whatever
 
Saturated arithmetic is not always the best solution, but for image analysis it's perfect. But most importantly, there's no arbitrary switching of types depending on the value of the scalar multiplier.
 
probably doesn't explain the difference, but they are not the same
 
@AndrasDeak--СлаваУкраїні That doesn't explain the fact that NumPy makes weird choices about the type of the output array.
 
for what it's worth there's a long discussion in the works to change this behaviour which might affect this numpy.org/neps/nep-0050-scalar-promotion.html
 
9:23 PM
I came to this because it turns out that img /= 10 is illegal in NumPy for an integer img array.
 
@CrisLuengo sounds like you want //= 10
 
@AndrasDeak--СлаваУкраїні That's right, I remember you pointing that out some time back. Thanks!
 
it's an admitted mess, but it's ancient history and hard to change
 
@AndrasDeak--СлаваУкраїні Yes, but img //= 100000 will still first create a int32 array with the result of the operation, and then cast and write into img. It's sooooo weird!
 
@CrisLuengo will it?
I would assume that ndarray.__itruediv__() uses the appropriate dtype
Note that a //= b is not a = a // b, it's a = a.__itruediv__(b).
 
9:27 PM
Well, img /= 100 creates a floating-point result, and tries to write that into img, which causes the error. I assume img //= 100000 will do img // 100000, which is int32, and then write that into img. Not 100% sure, but it's likely from what I see /= doing.
 
perhaps a memory profiler can give a conclusive result, I never play with those things
>>> img //= 100000
---------------------------------------------------------------------------
UFuncTypeError                            Traceback (most recent call last)
Cell In[101], line 1
----> 1 img //= 100000

UFuncTypeError: Cannot cast ufunc 'floor_divide' output from dtype('int32') to dtype('uint16') with casting rule 'same_kind'
default casting rule doesn't allow you to lose information
And note that the error doesn't necessarily imply that there was an array of type int32 created. It just means that the ufunc machinery tried to resolve the types and gave up.
this doesn't directly say anything about intermediate values, but I would assume it uses the more precise type
or not; I don't know
 
Yeah, you might be right. I jumped to conclusions there.
It's silly though, integer division never produces a value larger than the LHS input values. No matter what size the RHS integer is.
If the RHS scalar doesn't fit in the type of the LHS array, you know the results will be all zeros.
 
9:42 PM
so now you do want value-based promotion :P
 
No, I want no promotion. But the error it throws, which you say is because "default casting rule doesn't allow you to lose information", is bogus, you will never lose information in that cast. Because the result will be 0.
 
It doesn't say anything about losing information, I did
I think inplace magic method ufuncs are generated here github.com/numpy/numpy/blob/…
 
I guess they could special-case the division because the standard logic doesn't hold.
 
so it does img.floor_divide(100, out=img)
(I kept calling __ifloordiv__() __itruediv__())
based on that it's indeed likely that each item is computed first, then cast to the original dtype
i.e. same result as img[...] = img // 100 I think
 
It makes sense to do the operation in the larger type and then cast the result. As long as it does the computation and casting per element, and not using an intermediate array of different type, all is well.
 
9:55 PM
yeah, ufuncs work element by element looping in C
well, I guess I don't exactly know how out works
if it were to support directly casting a given array element, it would have to compile each pair of dtypes into its own function, which I doubt anyone would want to do
-15
A: A/B testing related questions within the answers list (experiment has graduated)

tanj92As you may have already noticed, we graduated the experiment to display related questions on pages that don't have answers yet. This module will only be shown on Stack Overflow question pages that don't have answers yet. Additionally, we are aware of the module appearing on other Stack Exchange n...

piece of shit feature again, colour me surprised
 
@AndrasDeak--СлаваУкраїні Higher click-through rate, meaning people notice it more, not meaning that the links in it are useful. This is the same box that used to be on the side, no?
 
@CrisLuengo same piece of shit one, yes
Makyen's answer pretty much says it all
 
10:19 PM
A/B testing with the wrong endpoints is not really useful.
 
well the key performance indicators are met
 

« first day (2820 days earlier)      last day (402 days later) »