octave-maintainers
[Top][All Lists]
Advanced

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

PATCH: octave-image, regionprops "WeightedCentroid" fails with 1 element


From: Andreas Weber
Subject: PATCH: octave-image, regionprops "WeightedCentroid" fails with 1 element regions
Date: Fri, 13 Sep 2013 09:36:37 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130827 Icedove/17.0.8

Dear maintainers,

WeightedCentroid fails with regions which has only 1 element.
Minimalistic example:

L = 1;
props = regionprops(L, "Centroid", "WeightedCentroid")
props =
  scalar structure containing the fields:
    Centroid =
       1   1
    WeightedCentroid =  2

It is because "dot" uses the first non-singleton dimension which is 2 in
the case of a single pixel region. This should fix it:

diff -r ff3db65873b9 inst/regionprops.m
--- a/inst/regionprops.m        Fri Sep 13 08:30:30 2013 +0200
+++ b/inst/regionprops.m        Fri Sep 13 09:32:41 2013 +0200
@@ -276,7 +276,7 @@
           C = all_coords (L == k, true, true);
           vals = I (L == k) (:);
           vals /= sum (vals);
-          retval (k).WeightedCentroid = [dot(C, repmat(vals, 1,
columns(C)))];
+          retval (k).WeightedCentroid = [dot(C, repmat(vals, 1,
columns(C)), 1)];
         endfor

       case "meanintensity"


I'll push it tomorrow if there is no veto.
Regards, Andy

-- 
Mit freundlichen Grüßen

Dipl.-Ing.(FH) Andreas Weber
Fakultät Elektrotechnik und Informationstechnik

Hochschule Offenburg - University of Applied Sciences Offenburg
Badstraße 24
77652 Offenburg
Telefon +49 781 205-386


reply via email to

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