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)
|
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 ;-)
|
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)
|
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:
|
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.
|
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:
|
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.
|
Wed 30 Aug 2017 09:51:37 AM UTC, comment #3:
|
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?)
|
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
|
Tue 29 Aug 2017 01:40:39 PM UTC, original submission:
|