7

I have a list of picture(Noting the ordering)

first: enter image description here second: enter image description here third: enter image description here forth: enter image description here

My target is get the 3D'image,Now I get the mask of it like following(If you use it,you should Binarize it by yourself)

enter image description here
Then
enter image description here
I can get the result by slices

Image3D[slices, BoxRatios -> {1, 1, 1}]

enter image description here

As you can see,the color transition of surface is so bad that you can see it clearly that it is made up of 4 pictures.For the smooth color transition we needs some sampled picture,then we use the Image3D build 3D-image.So the question is how to resample a list of image.If the target is a list of number,we can use ArrayResample like as:

In[1]:= ArrayResample[{1,2,3,4,5},9]
Out[1]= {1,3/2,2,5/2,3,7/2,4,9/2,5}

But the list is picture now.How to do it?Can Any body have a try?

m_goldberg
  • 107,779
  • 16
  • 103
  • 257
yode
  • 26,686
  • 4
  • 62
  • 167

2 Answers2

9

You can use ImageResize to resample the z-direction for your purpose.

imgs = Import /@ {
    "https://i.stack.imgur.com/CXvgm.jpg", 
    "https://i.stack.imgur.com/RJJnL.jpg", 
    "https://i.stack.imgur.com/xdbmR.jpg", 
    "https://i.stack.imgur.com/auRS8.jpg"};
mask = Import["https://i.stack.imgur.com/6S4Vj.png"];
slices = ImageMultiply[#, mask] & /@ imgs;

With[{img3d = Image3D[slices]},
 ImageResize[img3d, ImageDimensions[img3d]*{1, 1, 100}, 
  Resampling -> "Linear"]
 ]

With this, you get a smooth transition. You probably won't need 100 slices, so please adapt the resampling size and the even the Resampling method as you like.

Mathematica graphics

halirutan
  • 112,764
  • 7
  • 263
  • 474
shrx
  • 7,807
  • 2
  • 22
  • 55
  • @halirutan thanks for the edit; didn't have time to use the images in the question. – shrx Nov 23 '15 at 12:59
  • I'm sorry I rewrote your whole answer, but it is basically exactly what you had just with the original data which will hopefully end in more upvotes. I didn't see your answer until I had the code written down, so I decided to edit yours. I hope that's OK. +1 btw. – halirutan Nov 23 '15 at 12:59
4

If you want to resample the data, not only the resulting Image

imgData = ImageData /@ slices

(* Resample for 10 points in each dimension) *)
Image /@ ArrayResample[imgData, 10 {1, 1, 1}] // Image3D

(* If you need finer-grained z sampling) *)
Image /@ ArrayResample[imgData, 10 {2, 1, 1}] // Image3D[#, BoxRatios -> {1, 1, 1}] &

Here's a sample 3d Image resampled from 3x3 to 10x10.

3x3 image into 10x10 image

Aisamu
  • 2,618
  • 14
  • 17
  • Transform the 10 {1, 1, 1} to 10 {1, Sequence@@ImageDimensions[mask]}will fit me more,And thanks for your new thinking. – yode Nov 23 '15 at 13:51