Comments (11)
from connected-components-3d.
hello @william-silversmith ,i want to apply cc3d on segmentation result image containing multiple class and the dimensions of result image is 128128128
from connected-components-3d.
Here's what I suspect you want to do:
# Let multichannel be the segmentation image.
output = np.zeros(multichannel.shape, dtype=np.uint32)
for i in range(multichannel.shape[3]):
output[:,:,:,i] = cc3d.connected_components(multichannel[:,:,:,i])
If instead by multichannel, you don't mean mean a 4D image and instead mean simply an image with multiple label types (i.e. label 1 might be adjacent to label 2), just use cc3d normally, that's what it was designed for.
from connected-components-3d.
Here's what I suspect you want to do:
# Let multichannel be the segmentation image. output = np.zeros(multichannel.shape, dtype=np.uint32) for i in range(multichannel.shape[3]): output[:,:,:,i] = cc3d.connected_components(multichannel[:,:,:,i])If instead by multichannel, you don't mean mean a 4D image and instead mean simply an image with multiple label types (i.e. label 1 might be adjacent to label 2), just use cc3d normally, that's what it was designed for.
Thanks
this is 3d image showing all 3 axis, i want to apply cc3d on it. How will i pass the image to it? i have to convert it into array?
from connected-components-3d.
output_dir='./'
PNii = nibabel.load('./prediction/BraTS20_Training_368/prediction.nii.gz')
P = PNii.get_fdata()
print(P.shape)
#multichannel='./prediction/BraTS20_Training_368/prediction.nii.gz'
output = np.zeros(P.shape, dtype=np.uint32)
for i in range(P.shape[2]):
output[:,:,i] = cc3d.connected_components(output[:,:,i])
print(output.shape)
output=sitk.GetImageFromArray(output)
#get the save path
sitk.WriteImage(output,output_dir + 'new.nii.gz')
This is my code for apply cc3d and saving it into 3d image with .nii.gz format but the output image is blank image? Please tell me what mistake i am doing here.
Thanks
from connected-components-3d.
Hi sneh, it looks like you are passing a blank output to cc3d. However, the way you're doing it you'll run connected components on each 2D slice, which may not be what you want. The following will probably produce 3D connected components if P is a numpy array.
output_dir='./'
PNii = nibabel.load('./prediction/BraTS20_Training_368/prediction.nii.gz')
P = PNii.get_fdata()
output = cc3d.connected_components(P)
output=sitk.GetImageFromArray(output)
sitk.WriteImage(output,output_dir + 'new.nii.gz')
from connected-components-3d.
Hi sneh, it looks like you are passing a blank output to cc3d. However, the way you're doing it you'll run connected components on each 2D slice, which may not be what you want. The following will probably produce 3D connected components if P is a numpy array.
output_dir='./' PNii = nibabel.load('./prediction/BraTS20_Training_368/prediction.nii.gz') P = PNii.get_fdata() output = cc3d.connected_components(P) output=sitk.GetImageFromArray(output) sitk.WriteImage(output,output_dir + 'new.nii.gz')
then it gives following error:
TypeError: Type float64 not currently supported.
from connected-components-3d.
If your data is floating point, it's not supported. You'll have to find a way to convert it to integer labels. This could be as easy as P.astype(np.uint64)
.
from connected-components-3d.
@william-silversmith it worked . thank you. can we increase the intensity value? The image obtained from cc3d is not clear, very difficult to visualize.
from connected-components-3d.
I'm glad it worked! To visualize more easily, try casting the output to a float before passing it to save_images
. That functions re-normalizes floats to be more visible.
from connected-components-3d.
Closing this question due to inactivity. Please reopen if you still need help!
from connected-components-3d.
Related Issues (20)
- Applying Dust and largest_k dtype output option HOT 2
- dust sugnature HOT 1
- Massive memory Leak HOT 7
- 1D Array of 4 Elements Incorrect HOT 5
- Cannot find reference 'dust' in 'cc3d.py' HOT 2
- Question on comparing individual lesions between two masks based on the cc3d.statistics output. HOT 1
- Additional metrics support HOT 2
- Does cc3d also work with memmory-mapped numpy arrays and array-like data? HOT 14
- cc3d.statistics["bounding_boxes"] are wrong HOT 1
- largest_k fails for transposed arrays HOT 6
- About the lastest_k function HOT 4
- Statistics output HOT 7
- Question on the output of contacts HOT 9
- Periodic Boundary Conditions HOT 4
- Is the output label of largest_k ordered? HOT 2
- Add a better error for type support. HOT 4
- Any way to make this GPU Compatible? HOT 5
- voxel_connectivity_graph and contacts can not be applied in 2D label HOT 5
- Build Equivalence Table Two Z Slices at a Time
- cc3d.dust fails HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from connected-components-3d.