Opening command with NA and version 4.12.0
3
1
Entering edit mode
@jeanluclablee-9563
Last seen 8.2 years ago

Hello,

We have a new problem when using version 4.12.0 with the opening command:

    opening_img = opening(mat_bin, kern)

The mat_bin includes binary information but also NA to delineate the area of interest (border). With the previous versions, 4.8.3 and 4.10.1, the NA were correctly handled.

Using version 4.12.0, the resulting image shows unexpected border effects and includes huge values (1.797693e+308).

We noticed the morphological algorithms have changed to become faster. How handle NA with the new version?

Thank you in advance.

ebimage • 1.3k views
ADD COMMENT
0
Entering edit mode

Hi Jean Luc,

could you please provide a minimal reproducible example illustrating the issue?

Cheers,

Andrzej

ADD REPLY
0
Entering edit mode
Andrzej Oleś ▴ 750
@andrzej-oles-5540
Last seen 3.4 years ago
Heidelberg, Germany

Hi Jean Luc

I've just updated EBImage devel version 4.13.8 to address the issue of handling NA's by morphological operations. You are welcome to give it a try an confirm whether it works for you as expected. The handling of NA's in previous versions you mentioned (4.8.3 and 4.10.1) was not completely correct either.

To install the updated version, please use:

library(devtools)
install_github("aoles/EBImage")

I'm looking forward to hearing from you if there are any remaining problems. If not, I will push the fix to release as well.

Cheers,

Andrzej

ADD COMMENT
0
Entering edit mode
@jeanluclablee-9563
Last seen 8.2 years ago

Thank you very much Andrzej for you quick answer.

But, the result is not the expected one.

To make sure we share the same information, the data as well the two results are available in a web page.

The code to run is:

    kern = matrix(c(1,1,1,1), ncol=2)
    opening_img = opening(as.matrix(read.table("http://ser.gui.free.fr/EBImage/opening_input.txt")), kern)


The resulting images are named with the package version:

http://ser.gui.free.fr/EBImage/opening_output_with_EBImage_4.13.8.txt

http://ser.gui.free.fr/EBImage/opening_output_with_EBImage_4.8.3.txt

Thanks again for you help.

Cheers,

Jean-Luc and Serge

 

 

ADD COMMENT
0
Entering edit mode

Hi Jean-Luc, Serge,

thank you for providing your sample code along with the data.

Please be aware that EBImage 4.13.8 won't give you identical results to those from previous versions, because in the previous implementations images containing NA's were not supported. In fact, functions performing morphological operations were never tested against such images. Even though they didn't break or give any obvious errors when applied to images containing NA's, the results were not correct. I would argue that if x is the original image, then the following should hold

identical(is.na(x), is.na(f(x)))

where f is any morphological function, such as erode, dilate, opening, or closing. According to their definition, NA's are treated as missing values, so they neither contribute to the filtering process, nor should they be affected by it.

You can easily check that this condition was not fulfilled before.

The updated version 4.13.8 makes sure that NA's are retained. You are welcome to review the following example visualizing the results of various morphological operations applied to your sample image. Please note that I use an odd-sized kernel, otherwise the results wouldn't be symmetrical.

library(EBImage)

kern = matrix(1, 3, 3)

x = as.matrix(read.table("http://ser.gui.free.fr/EBImage/opening_input.txt"))
e = erode(x, kern)
d = dilate(x, kern)
o = opening(x, kern)

identical(is.na(x), is.na(o))

img = combine(x, e, d, o)
img[is.na(img)] = .5
display(img, method = "raster", all=TRUE, interpolate=FALSE)
ADD REPLY
0
Entering edit mode
@jeanluclablee-9563
Last seen 8.2 years ago

Thanks a lot Andrzej!

You're right:  we had to mask the result to get the expected border using version 4.8.3.

The behavior with version 4.13.8 is correct: congratulations!

Jean-Luc and Serge

ADD COMMENT

Login before adding your answer.

Traffic: 486 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6