help-octave
[Top][All Lists]
Advanced

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

Re: sub2ind: index out of range


From: Carnë Draug
Subject: Re: sub2ind: index out of range
Date: Mon, 11 Nov 2013 14:45:37 +0000

On 11 November 2013 14:33, Gokhan Acer <address@hidden> wrote:
>
> On Thu, Nov 7, 2013 at 9:30 AM, Carnë Draug <address@hidden> wrote:
>>
>> On 6 November 2013 13:18, Gokhan Acer <address@hidden> wrote:
>> > Hi,
>> >
>> > I try to use image package on octave.
>> > When I use bwconncomp function,
>> > there is a bug :
>> >
>> > error: sub2ind: index out of range
>> >
>> > error: called from:
>> >
>> > error:   /Users/gokhanacer/octave/image-2.0.0/bwconncomp.m at line 61,
>> > column 12
>> >
>> > error:
>> >
>> > /Users/gokhanacer/Desktop/deneme_matlab/imge_isleme_dersi/Octave/OctaveDeneme.m
>> > at line 20, column 4
>> >
>> >
>> > How Can I solve this problem?
>> >
>> > Is there experiencing this specific problem?
>>
>> I think there is a bug, yes. Can you swap the 1 and 2 in that line,
>> i.e, change it so that it reads:
>>
>>     P{k} = sub2ind (size (bw), B{k}(:, 1), B{k}(:, 2));
>>
>> Please report back whether that solves your problem or not.
>>
>> Carnë
>
> Helle Everyone,
>
> I tried. But I don't solve this problem.
> I'm sharing my code. It works on Matlab.
> But on octave, it doesn't.
>
> My code and result:
>
> %%
> clc; clear all; close all;
> n = 3;
>
> I1 = imread('~/Desktop/ip/socialtv/a.jpg');
> I2= rgb2gray(I1);
> [w,h] = size(I1);
> I5 = edge(I2,'log');
> I3 = esikle(I2,n);
> I6 = xor(I3, I5) | I5;
>
> h = 1/9*ones(3,3);
> H = h*h';
> I7 = filter2(H,I6);
> I7 = conv2(single(I6), H);
> I8 = medfilt2(I7, [3 3]);
> I9 = edge(I8,'canny');
>
> BW = I6;
>
> cc = bwconncomp(BW,4);
> %cc = sub2ind (size (BW), B{k}(:, 1), B{k}(:, 2));
> %cc = sub2ind(bwconncomp(BW));
> stats = regionprops(cc, 'Area');
> idx = find([stats.Area] > 10000 & [stats.Area] < 200000);
> BW2 = ismember(labelmatrix(cc), idx);
>
> figure; imshow(I1,[]);
> figure; imshow(I2,[]);
> figure; imshow(I3);
> figure; imshow(I5);
> figure; imshow(I6);
> figure; imshow(I7);
> figure; imshow(I8);
> figure; imshow(I9);

Do not forget to include the mailing list when replying. Can you give
us a self contained example to replicate the problem? We don't even
have the image you are using to make the bug manifest. If you are
seeing a problem with bwconncomp, a self contained example would be
something like:

"The following is giving an error:

im = [.......];
bwconncomp (im, 4);
"

Anyway, I have rewritten that function last week so could you please
try the development version [1]? The main difference is that
PixelIdxList now is the indices for all object pixels/voxels instead
of the indices for the objects perimeters. In addition, it will accept
the many differents ways to set connectivity, and images with any
number of dimensions.

Carnë

[1] https://sourceforge.net/p/octave/image/ci/default/tree/inst/bwconncomp.m


reply via email to

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