[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Octave-bug-tracker] [bug #54567] median(uint8) gives bad results

From: Dan Sebald
Subject: [Octave-bug-tracker] [bug #54567] median(uint8) gives bad results
Date: Fri, 24 Aug 2018 15:22:27 -0400 (EDT)
User-agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:61.0) Gecko/20100101 Firefox/61.0

Follow-up Comment #1, bug #54567 (project octave):

The question is whether Matlab does the arithmetic using the intrinsic
variable type.  The median() routine is supposed to return the same variable
type, but that doesn't necessarily mean the average of the center values
should be computed using that type.  Why should it, I guess?  In fact, mean()
appears to do its arithmetic not using native, but instead converts it

octave:12> u = [1 140 140 255];
octave:13> u8 = uint8(u);
octave:14> mean(u)
ans =  134
octave:15> mean(u8)
ans =  134

So, attached a patch to change the behavior for median.  Basically it uses
mean() instead of sum() with the assumption that the proper averaging behavior
is already baked into mean().  I added a couple more tests as well.

(file #44857)

Additional Item Attachment:

File name: octave-median_even_averaging-djs2018aug24.patch Size:1 KB


Reply to this item at:


  Message sent via Savannah

reply via email to

[Prev in Thread] Current Thread [Next in Thread]