My goal is to receive the volume of red and blue area. Here is my algorithm.
- Get the leftmost and rightmost coordinate in red slice window.
- Go through the image, and fill the hole by replacing 0 with 1, then the blue area can be created.
My problems are:
- Because red and black area are two volume, I also wonder that if is possible to combine them into one labelmap volume. Since the the slice window can only show one labelmap in one time.
- map and visualize the point in 2d slice into 3d view. I used TransformIndexToPhysicalPoint() and fiducial node before, but the position was weird.
# It doesn't look like situated at the corner.
index= (image.GetSize(), image.GetSize(), image.GetSize())
I will explain my problem in detail below.
Now I’m trying to find the coordinate of green line in the red slice window. Just like the picture below. I want to go through every slice in red slice window and find the coordinates.
I first cut the image into 2d named target image for testing.
Once I touch a point that value is not zero, I break the loop.
I want to know how to check this point’s coordinate in 3d view, in order to check this code works. Then I can modify the parameters to find the coordinates of green line.
Here is my code:
image = sitkUtils.PullVolumeFromSlicer(test_volume)
direction = image.GetDirection()
image = sitk.Flip(image, [direction < 0, direction < 0, direction < 0])
image_shape = image.GetSize()
target_img = image[0:image_shape-1, 0:image_shape-1, 0]
array = sitk.GetArrayFromImage(target_img)
for j in range(image_shape-1):
for k in range(image_shape-1):
# I want to know how to map this point to 3d view.