Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

index error in ocontour #65

Open
ma-ho opened this issue Mar 28, 2023 · 1 comment
Open

index error in ocontour #65

ma-ho opened this issue Mar 28, 2023 · 1 comment
Labels

Comments

@ma-ho
Copy link

ma-ho commented Mar 28, 2023

Hi,

apparently, ocontour returns 0-based index matrices
while R requires 1-based indices.

As an example, consider the mask image:

msk = as.Image(matrix(0,nrow=5,ncol=5))
msk[,3] = msk[3,] = msk[2,2] = msk[2,4] = msk[4,2] = msk[4,4] = 1
msk

Image
colorMode : Grayscale
storage.mode : double
dim : 5 5
frames.total : 1
frames.render: 1

imageData(object)[1:5,1:5]
[,1] [,2] [,3] [,4] [,5]
[1,] 0 0 1 0 0
[2,] 0 1 1 1 0
[3,] 1 1 1 1 1
[4,] 0 1 1 1 0
[5,] 0 0 1 0 0

Then ocontour of msk outputs:

con = ocontour(msk)[[1]]
con

[,1] [,2]

[1,] 2 0
[2,] 1 1
[3,] 0 2
[4,] 1 3
[5,] 2 4
[6,] 3 3
[7,] 4 2
[8,] 3 1

while the 1-based output would be
con+1

 [,1] [,2]

[1,] 3 1
[2,] 2 2
[3,] 1 3
[4,] 2 4
[5,] 3 5
[6,] 4 4
[7,] 5 3
[8,] 4 2

I am running R version 4.2.3 (2023-03-15) with EBImage_4.38.0 attached.

@aoles aoles added the bug label Apr 4, 2023
@aoles
Copy link
Owner

aoles commented Apr 4, 2023

Thanks for reporting this! Indeed, looks like a bug to me. In case you have started looking into a fix, please feel free to submit a PR. Cheers!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants