bugGNU Octave - Bugs: bug #51884, [octave forge] (image)...

 
 

bug #51884: [octave forge] (image) bwmorph(blackNwhiteMatrix, "thicken", 1) returns negated result (+ strange behavior at border)

Submitted by:  None
Submitted on:  Tue 29 Aug 2017 01:40:39 PM UTC  
 
Category: Octave Forge PackageSeverity: 3 - Normal
Priority: 5 - NormalItem Group: Incorrect Result
Status: NoneAssigned to: None
Originator Name: hans messnerOriginator Email: -unavailable-
Open/Closed: OpenRelease: 4.2.1
Operating System: GNU/Linux

Add a New Comment(Rich Markup)
   

You are not logged in

Please log in, so followups can be emailed to you.

 

(Jump to the original submission Jump to the original submission)

Tue 05 Sep 2017 07:44:25 PM UTC, comment #10:

You are right, this wasn't enough padding, yet. Thanks for spotting this.

Here is a new PATCH (HG2 in file name) to fix this, including the additional test from comment #9.

(file #41737)

Hartmut <hardy>
Mon 04 Sep 2017 08:24:52 PM UTC, comment #9:

I guess the "border" (padding margin) to be added needs to be large enough. Otherwise we might fail to reach the corners. Please test your (HG1 version; attached file #41717) this
way:

If we use a large enough (say patch version HG1.1) padding
as in code:

Now, even our "academic" (synthetic) test case works (the image gets filled up for n=4):

I guess this relates to the fact that the "thicken" operation actually is implemented by its dual: thinning of the background.

Thanks for the code cleanup (I learned more about GNU Octave ;-)

Anonymous
Sat 02 Sep 2017 10:52:10 AM UTC, comment #8:

I've cleaned up your code a bit, and wrapped it into a PATCH file (attached as HG1 version). Have a look at it.

Thanks for the code suggestion again.

Now we'll have to wait for the package maintainer (Carné) to review this and probably add this to the image repository (and then this would go to the next release of the image package).

(file #41717)

Hartmut <hardy>
Thu 31 Aug 2017 07:33:32 AM UTC, comment #7:

In order to get a correct (i.e. not negated) result for "n==0" we
test for this case ...

Test case:

Anonymous
Wed 30 Aug 2017 04:58:46 PM UTC, comment #6:

Thanks for your code suggestions, Hans. I'll try to have a closer look during the following days.

Hartmut <hardy>
Wed 30 Aug 2017 10:33:49 AM UTC, comment #5:

// this is the final edition (I hope)

This is my suggestion for the "thicken" case:

Some Tests:

Anonymous
Wed 30 Aug 2017 10:03:30 AM UTC, comment #4:

sorry for the HTML character encoding of my posting below ...
(perhaps I should not have done a preview before ;-)

case "thicken";
## This implementation also "thickens" the border. To avoid this,
## a simple solution could be to add a border of 1 to the reversed
## image.

## 30-Aug-2017 MeJ:: going for a >>bwmorph(bw, 'thicken', n)<<; with "add border workaround"
max_dim = max( size(bw) );
add_border = 2 * ( min([ ceil(max_dim/2), n ]) );
bw_framed = false(size(bw,1)+(2add_border),size(bw,2)+(2add_border));
lb1 = (add_border+1); ub1 = (size(bw,1)+add_border);
lb2 = (add_border+1); ub2 = (size(bw,2)+add_border);
bw_framed(lb1:ub1,lb2:ub2) = bw;
bw = ! bwmorph (! bw_framed, "thin", n);
loop_once = true;
morph = @(x) bwmorph (x, "diag");
post_morph = @(x) x(lb1:ub1,lb2:ub2);

## --------- original code fragement (as of octave forge package image 2.6.1)
## bw = bwmorph (! bw, "thin", n);
## loop_once = true;
## morph = @(x) bwmorph (x, "diag");

Testing:
---------

octave: test_bw = false(8,7); test_bw(6,3)=true; disp(test_bw);
0 0 0 0 0 0 0
0 0 0 0 0 0 0
0 0 0 0 0 0 0
0 0 0 0 0 0 0
0 0 0 0 0 0 0
0 0 1 0 0 0 0
0 0 0 0 0 0 0
0 0 0 0 0 0 0

octave: thickened_bw=bb=bwmorph(test_bw, "thicken", 1); disp(thickened_bw);
0 0 0 0 0 0 0
0 0 0 0 0 0 0
0 0 0 0 0 0 0
0 0 0 0 0 0 0
0 0 1 0 0 0 0
0 1 1 1 0 0 0
0 0 1 0 0 0 0
0 0 0 0 0 0 0

octave: thickened_bw=bb=bwmorph(test_bw, "thicken", 3); disp(thickened_bw);
0 0 0 0 0 0 0
0 0 0 0 0 0 0
0 0 1 0 0 0 0
0 1 1 1 0 0 0
1 1 1 1 1 0 0
1 1 1 1 1 1 0
1 1 1 1 1 0 0
0 1 1 1 0 0 0

# I am no expert in this area ... but the results look reasonable.

Anonymous
Wed 30 Aug 2017 09:51:37 AM UTC, comment #3:
Anonymous
Tue 29 Aug 2017 06:16:40 PM UTC, comment #2:

Here is the current source code (just type "edit bwmorph" to see it):

Do you have a good suggestion how to improve this code (the "case thicken" section) with your current insight into the topic? Could you include your workaround into the code in a good way? (Or would you say that the problem is already in the "thin" subroutine?)

Hartmut <hardy>
Tue 29 Aug 2017 02:47:33 PM UTC, comment #1:

In case you want to "thicken" with width 'w' you will have to use an extra border at least of size w+1 in the workaround

Anonymous
Tue 29 Aug 2017 01:40:39 PM UTC, original submission:
Anonymous

 

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

Attach File(s):
   
   
Comment:
   

Attached Files

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -unavailable- added by hardy (Posted a comment)
  • -unavailable- added by hardy
  • -unavailable- added by hardy
  • -unavailable- added by jwe (Updated the item)
  • -unavailable- added by None (Submitted the item)
  •  

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only project members can vote.

     

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    Follow 5 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Tue 05 Sep 2017 07:44:25 PM UTChardyAttached File-=>Added bwmorph_thicken_padding_HG2.patch, #41737
    Sat 02 Sep 2017 10:52:10 AM UTChardyAttached File-=>Added bwmorph_thicken_padding_HG1.patch, #41717
    Tue 29 Aug 2017 06:16:40 PM UTChardyCarbon-Copy-=>Added avinoam
      Carbon-Copy-=>Added carandraug
    Tue 29 Aug 2017 01:49:15 PM UTCjweSummarybwmorph(blackNwhiteMatrix, "thicken", 1) returns negated result (+ strange behavior at border)=>[octave forge] (image) bwmorph(blackNwhiteMatrix, "thicken", 1) returns negated result (+ strange behavior at border)

    Back to the top


    Powered by Savane 3.1-cleanup1