idaholab / moose

Multiphysics Object Oriented Simulation Environment
https://www.mooseframework.org
GNU Lesser General Public License v2.1
1.65k stars 1.02k forks source link

Add a reading 3D Tiff feature in `ImageSampler` #13006

Open shoheiogawa opened 5 years ago

shoheiogawa commented 5 years ago

Rationale

Currently, we have to give Moose a stack of images to construct a 3D array out of images in a domain. Considering a single Tiff file can have 3D information and VTK supports reading 3D Tiff images, this feature improves the users experience to use images with Moose.

Description

Related VTK thread: http://vtk.1045678.n5.nabble.com/Reading-a-simple-3D-tiff-td5713460.html

Impact

Minor as this is a new feature.

permcody commented 5 years ago

@shoheiogawa - Are you planning to work on this enhancement?

shoheiogawa commented 5 years ago

I want to work on this. I started taking a look at the code around ImageSampler.

permcody commented 5 years ago

Great! Let us know if you have any questions.

shoheiogawa commented 5 years ago

I have been able to read a 3D Tiff file with this commit below. In addition to what I changed in the code, I added an input file and sample 3D Tiff file of 8-bit unsigned int which should result in like a picture below. I also have the same data but in different data types (not included to this commit).

https://github.com/shoheiogawa/moose/commit/845d2dccf6adec2fdf916108e4bccf13af1130bb

tiff3d_uint8

I note that this might change the behavior to read a single 2D Tiff file since I set the file dimension 3D in any case where only one Tiff file is given. I am not sure how to make sure there is no change.

shoheiogawa commented 5 years ago

Also, as far as I tried, having

_image->SetFileNames(_files);
_image->SetFileDimensionality(3)

for a 3D Tiff file input causes a crush so I have

_image->SetFileName(_files->GetValue(0));
_image->SetFileDimensionality(3);

instead.

shoheiogawa commented 5 years ago

On my local, all the tests pass. However, this might not useful since as far as I know, there is no test related to reading Tiff format images (the existing tests are only PNG format), so I cannot tell if the result is different or not due to the changes I made.

permcody commented 5 years ago

Add a test! Let's see how it works on our test boxes.

On Tue, Mar 12, 2019 at 4:25 PM Shohei Ogawa notifications@github.com wrote:

On my local, all the tests pass. However, this might not useful since as far as I know, there is no test related to reading Tiff format images (the existing tests are only PNG format), so I cannot tell if the result is different or not due to the changes I made.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/idaholab/moose/issues/13006#issuecomment-472204909, or mute the thread https://github.com/notifications/unsubscribe-auth/AC5XIISjyBYOOjiGxcEogF0CGf5ZCRXSks5vWClKgaJpZM4bheUz .

shoheiogawa commented 5 years ago

Are there any documents about tests (input file specification, type of test, etc)? I didn't find details much in the Moose document website.

Also, as far as I tried using exodiff, there is no difference between the result with/without changes for a single 2D image. I am going to add tests for 2D Tiff and stack first.

shoheiogawa commented 5 years ago

I created an issue for 2D Tiff image testing

13065