|
| From: | anonymous |
| Subject: | [Octave-bug-tracker] [bug #54567] median(uint8) gives bad results |
| Date: | Fri, 24 Aug 2018 11:50:41 -0400 (EDT) |
| User-agent: | Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36 |
URL:
<http://savannah.gnu.org/bugs/?54567>
Summary: median(uint8) gives bad results
Project: GNU Octave
Submitted by: None
Submitted on: Fri 24 Aug 2018 03:50:40 PM UTC
Category: Octave Function
Severity: 3 - Normal
Priority: 5 - Normal
Item Group: Incorrect Result
Status: None
Assigned to: None
Originator Name: Etienne de Foras
Originator Email: address@hidden
Open/Closed: Open
Discussion Lock: Any
Release: 4.4.1
Operating System: Microsoft Windows
_______________________________________________________
Details:
If I define:
u= [1 140 140 255];
u8=uint8(u);
then median(u)=140 (correct)
but median(u8)=128 (incorrect, should be 140)
The bug disappear with odd size data, the median with even size data is
computed as (140+140)/2, but with saturation to 255 due to uint8 type and then
divided by two ->127 (or 128 with rounding).
We may use the type int32 or double for the sum and division by 2 and then
convert back to uint8
(Thanks for GNU Octave !)
_______________________________________________________
Reply to this item at:
<http://savannah.gnu.org/bugs/?54567>
_______________________________________________
Message sent via Savannah
https://savannah.gnu.org/
| [Prev in Thread] | Current Thread | [Next in Thread] |