bugGNU Octave - Bugs: bug #38464, image: regionprops misses some...

 
 

bug #38464: image: regionprops misses some pixels?

Submitter:  Juan Pablo Carbajal <juanpi>
Submitted:  Mon 04 Mar 2013 06:54:08 PM UTC
   
 
Category:  Octave Package Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Inaccurate Result
Status:  Duplicate Assigned to:  None
Originator Name:  juanpi Open/Closed:  * Closed
Release:  * 3.6.4 Operating System:  * GNU/Linux
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Jump to the original submission

Sun 03 Nov 2013 05:40:45 AM UTC, comment #7: 

So I took a closer look to this, compared with Matlab and Octave's image package old and development release and swapping the order on the call to plot. The bug is fixed now (it's a duplicate of bug #39701).

The code in the original submission is wrong. Even in Matlab is wrong, the coordinates are swapped. If they are fixed as suggested on comment #4, then it works in Matlab. I'm guessing the reason why they were swapped to start with is because of bug #39701 (now fixed) that caused regionprops to soemtimes return the Centroid coordinates swap (and in the attached image it was doing it for most of the objects) so swapping was actually trying to fix it (but then the correct ones were wrong).

Current version of the Octave package (cset 939332b5142e) works fine and I don't see any object being missed. If I undo cset ab0ac77d350b (which fixed bug #39701) then I get a big mess. Swapping back the coordinates to the wrong order, it plots the circle on most of the centroid coordinates and looks like it's missing some objects but in reality it's just drawing them in other places. The ones being drawn correctly (the majority) are actually the ones with the wrong coordinates that regionprops was swapping.

Closing as duplicate.

Carnë Draug <carandraug>
Group Member
Sun 03 Nov 2013 03:27:07 AM UTC, comment #6: 

@Carne,

Can you try the code on the original submission and see what is the problem there? Maybe is an issue that wasn't correctly identified.

Juan Pablo Carbajal <juanpi>
Group Member
Sat 02 Nov 2013 08:36:26 PM UTC, comment #5: 

@JuanPi

So Matlab also misses some of the points?

No. Matlab's bwlabel doesn't miss any of the points, and neither does Octave. The bwlabel function will label any non-zero pixel in the image with a positive number. We can confirm that it does not miss any of the points with the following:


lblNodes = bwlabel (imgNodes);
isequal (lblNodes > 0, imgNodes);


While the bwlabel function has changed since this report, the above still returns true when using the lblNodes variable present on the bwlabel_miss.mat file.

It is possible that bwlabel may be labeling two separate objects as being the same, but it's certainly not missing any pixel.

Carnë Draug <carandraug>
Group Member
Sat 02 Nov 2013 05:02:55 PM UTC, comment #4: 

The script in the "original submission" shows an image and plots which are bsed on data in bwlabel_miss.mat.

"lblNodes" in bwlabel_miss.mat shows no error and
"data" is missing. If I create nodes with a current regionprops from hg sources it includes all regions.

Please mention that there is an error in your script:
When generating

data     = regionprops (lblNodes, "Centroid");
nodes    = zeros (length (data), 2);
for i=1:length (data)
      nodes(i, [2 1]) = data(i).Centroid;
end


and plotting nodes with

plot(nodes(:,1),nodes(:,2),"om")


x and y is swapped. I I use your original script and change x/y:

plot(nodes(:,2),nodes(:,1),"om")


all regions are shown.

Andreas Weber <andy1978>
Group Member
Sat 02 Nov 2013 03:06:41 PM UTC, comment #3: 

So Matlab also misses some of the points?

Running the script i the original submission still generates a quite disappointing result.

Juan Pablo Carbajal <juanpi>
Group Member
Fri 01 Nov 2013 04:58:34 PM UTC, comment #2: 

I just compared against the results that Matlab gives when using bwlabel, and the bug is (was?) definitely not in our bwlabel.

Carnë Draug <carandraug>
Group Member
Fri 01 Nov 2013 01:41:55 PM UTC, comment #1: 

I tired your test with an image development build from 3.10.2013

pkg load image
load "bwlabel_miss.mat"
clear lblNodes codes

lblNodes = bwlabel (imgNodes, 4);
data     = regionprops (lblNodes, "Centroid");
nodes    = cat(1, data.Centroid);

imshow (imgNodes);
hold on
plot(nodes(:,1),nodes(:,2),"om")


and I see all regions. Perhaps this http://sourceforge.net/p/octave/image/ci/ab0ac77d350bb005869498833fbb4427dc4fc933/tree/inst/regionprops.m?diff=b2e168a18d4b443870198eabf6dcfc3de239ba54 changeset fixed it. Can you check your test with the hg sources of image?

Regards, Andy

Andreas Weber <andy1978>
Group Member
Mon 04 Mar 2013 06:54:08 PM UTC, original submission:  


Execute the following script (fiel with data attached)


load "bwlabel_miss.mat"
imshow (imgNodes);
hold on
plot(nodes(:,1),nodes(:,2),"om")


You see that some nodes are not plotted. The matrix lblNodes (also in the file) and the matrix nodes were generated with the following script


lblNodes = bwlabel (imgNodes, 4);
data     = regionprops (lblNodes, "Centroid");
nodes    = zeros (length (data), 2);
for i=1:length (data)
      nodes(i, [2 1]) = data(i).Centroid;
end


Apparently bwlabel nodes misses some of the pixels.
I checked that regionpropos is giving the correct result with other images.

Juan Pablo Carbajal <juanpi>
Group Member

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

Attached Files
file #27565:  bwlabel_miss.mat added by juanpi (158KiB - application/octet-stream)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by andy1978 (Posted a comment)
  • -email is unavailable- added by juanpi (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only group members can vote.

     

    Follow 4 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2013-11-03 carandraug StatusNone Duplicate
        Open/ClosedOpen Closed
    2013-11-01 carandraug SummaryIMAGE: bwlabel misses some pixels? image: regionprops misses some pixels?
    2013-03-04 juanpi Attached File- Added bwlabel_miss.mat, #27565

    Back to the top

    Powered by Savane 3.13-4448.
    Corresponding source code