[prev in list] [next in list] [prev in thread] [next in thread]
List: insight-users
Subject: [ITK-users] How to using SimpleITK to change the voxel value without touch the metadata
From: Po-Yu Kao <poyu_kao () ece ! ucsb ! edu>
Date: 2017-11-29 2:32:54
Message-ID: CA+pTWFT1kn2tq3bdOzsfeedGVetxoBX99MmOF9PuZ296nbk0jg () mail ! gmail ! com
[Download RAW message or body]
[Attachment #2 (multipart/alternative)]
Hello,
I am using SimpleITK library in python 2.7.
I want to do some basic preprocessing on CT scans with nii.gz. format. For
example, I use img = sitk.ReadImage(ct_scan_path) to read the image, and
then use nda = sitk.GetArrayFromImage(ct_img) to access n-dimensional numpy
array. Then, I do some preprocessing steps on this n-dimensional numpy, and
save it back to the image format by using img_preprocessed =
sitk.GetImageFromArray(nda_preprocessed). However, when I check the
metadata of these two images, it gives me different values which are showed
below.
Does anyone know how to copy all the metadata from the original image to
another image? or Does anyone know how to access and change the voxel value
of the image without touching the metadata?
Original Image:
print img
Image (0x4237b40)
RTTI typeinfo: itk::Image<float, 3u>
Reference Count: 1
Modified Time: 3601
Debug: Off
Object Name:
Observers:
none
Source: (none)
Source output name: (none)
Release Data: Off
Data Released: False
Global Release Data: Off
PipelineMTime: 3578
UpdateMTime: 3600
RealTimeStamp: 0 seconds
LargestPossibleRegion:
Dimension: 3
Index: [0, 0, 0]
Size: [512, 512, 37]
BufferedRegion:
Dimension: 3
Index: [0, 0, 0]
Size: [512, 512, 37]
RequestedRegion:
Dimension: 3
Index: [0, 0, 0]
Size: [512, 512, 37]
Spacing: [0.488281, 0.488281, 5]
Origin: [-114, 294.012, 21.82]
Direction:
1 0 0
0 -1 0
0 0 1
IndexToPointMatrix:
0.488281 0 0
0 -0.488281 0
0 0 5
PointToIndexMatrix:
2.048 0 0
0 -2.048 0
0 0 0.2
Inverse Direction:
1 0 0
0 -1 0
0 0 1
PixelContainer:
ImportImageContainer (0x398e780)
RTTI typeinfo: itk::ImportImageContainer<unsigned long, float>
Reference Count: 1
Modified Time: 3597
Debug: Off
Object Name:
Observers:
none
Pointer: 0x7f6ef9225010
Container manages memory: true
Size: 9699328
Capacity: 9699328
Preprocessed Image:
Image (0x3857e60)
RTTI typeinfo: itk::Image<float, 3u>
Reference Count: 1
Modified Time: 3605
Debug: Off
Object Name:
Observers:
none
Source: (none)
Source output name: (none)
Release Data: Off
Data Released: False
Global Release Data: Off
PipelineMTime: 0
UpdateMTime: 0
RealTimeStamp: 0 seconds
LargestPossibleRegion:
Dimension: 3
Index: [0, 0, 0]
Size: [512, 512, 37]
BufferedRegion:
Dimension: 3
Index: [0, 0, 0]
Size: [512, 512, 37]
RequestedRegion:
Dimension: 3
Index: [0, 0, 0]
Size: [512, 512, 37]
Spacing: [1, 1, 1]
Origin: [0, 0, 0]
Direction:
1 0 0
0 1 0
0 0 1
IndexToPointMatrix:
1 0 0
0 1 0
0 0 1
PointToIndexMatrix:
1 0 0
0 1 0
0 0 1
Inverse Direction:
1 0 0
0 1 0
0 0 1
PixelContainer:
ImportImageContainer (0x39856c0)
RTTI typeinfo: itk::ImportImageContainer<unsigned long, float>
Reference Count: 1
Modified Time: 3606
Debug: Off
Object Name:
Observers:
none
Pointer: 0x7f6ef4823010
Container manages memory: true
Size: 9699328
Capacity: 9699328
[Attachment #5 (text/html)]
<div dir="ltr"><div><div><div>Hello,</div><div><br></div><div>I am using SimpleITK \
library in python 2.7. <br></div><div><br></div>I want to do some basic preprocessing \
on CT scans with nii.gz. format. For example, I use img = \
sitk.ReadImage(ct_scan_path) to read the image, and then use nda = \
sitk.GetArrayFromImage(ct_img) to access n-dimensional numpy array. Then, I do some \
preprocessing steps on this n-dimensional numpy, and save it back to the image format \
by using img_preprocessed = sitk.GetImageFromArray(nda_preprocessed). However, when I \
check the metadata of these two images, it gives me different values which are showed \
below.</div><div><br></div><div>Does anyone know how to copy all the metadata from \
the original image to another image? or Does anyone know how to access and change the \
voxel value of the image without touching the \
metadata?<br></div><div><br></div>Original Image:<br></div>print img<br> \
<br><div><div>Image (0x4237b40)<br> RTTI typeinfo: itk::Image<float, \
3u><br> Reference Count: 1<br> Modified Time: 3601<br> Debug: Off<br> \
Object Name: <br> Observers: <br> none<br> Source: (none)<br> Source \
output name: (none)<br> Release Data: Off<br> Data Released: False<br> Global \
Release Data: Off<br> PipelineMTime: 3578<br> UpdateMTime: 3600<br> \
RealTimeStamp: 0 seconds <br> LargestPossibleRegion: <br> Dimension: 3<br> \
Index: [0, 0, 0]<br> Size: [512, 512, 37]<br> BufferedRegion: <br> \
Dimension: 3<br> Index: [0, 0, 0]<br> Size: [512, 512, 37]<br> \
RequestedRegion: <br> Dimension: 3<br> Index: [0, 0, 0]<br> Size: \
[512, 512, 37]<br> Spacing: [0.488281, 0.488281, 5]<br> Origin: [-114, 294.012, \
21.82]<br> Direction: <br>1 0 0<br>0 -1 0<br>0 0 1<br><br> IndexToPointMatrix: \
<br>0.488281 0 0<br>0 -0.488281 0<br>0 0 5<br><br> PointToIndexMatrix: <br>2.048 0 \
0<br>0 -2.048 0<br>0 0 0.2<br><br> Inverse Direction: <br>1 0 0<br>0 -1 0<br>0 0 \
1<br><br> PixelContainer: <br> ImportImageContainer (0x398e780)<br> \
RTTI typeinfo: itk::ImportImageContainer<unsigned long, float><br> \
Reference Count: 1<br> Modified Time: 3597<br> Debug: Off<br> \
Object Name: <br> Observers: <br> none<br> Pointer: \
0x7f6ef9225010<br> Container manages memory: true<br> Size: \
9699328<br> Capacity: 9699328</div><div><br></div><div>Preprocessed \
Image:</div><div><br></div><div>Image (0x3857e60)<br> RTTI typeinfo: \
itk::Image<float, 3u><br> Reference Count: 1<br> Modified Time: 3605<br> \
Debug: Off<br> Object Name: <br> Observers: <br> none<br> Source: \
(none)<br> Source output name: (none)<br> Release Data: Off<br> Data Released: \
False<br> Global Release Data: Off<br> PipelineMTime: 0<br> UpdateMTime: 0<br> \
RealTimeStamp: 0 seconds <br> LargestPossibleRegion: <br> Dimension: 3<br> \
Index: [0, 0, 0]<br> Size: [512, 512, 37]<br> BufferedRegion: <br> \
Dimension: 3<br> Index: [0, 0, 0]<br> Size: [512, 512, 37]<br> \
RequestedRegion: <br> Dimension: 3<br> Index: [0, 0, 0]<br> Size: \
[512, 512, 37]<br> Spacing: [1, 1, 1]<br> Origin: [0, 0, 0]<br> Direction: \
<br>1 0 0<br>0 1 0<br>0 0 1<br><br> IndexToPointMatrix: <br>1 0 0<br>0 1 0<br>0 0 \
1<br><br> PointToIndexMatrix: <br>1 0 0<br>0 1 0<br>0 0 1<br><br> Inverse \
Direction: <br>1 0 0<br>0 1 0<br>0 0 1<br><br> PixelContainer: <br> \
ImportImageContainer (0x39856c0)<br> RTTI typeinfo: \
itk::ImportImageContainer<unsigned long, float><br> Reference Count: \
1<br> Modified Time: 3606<br> Debug: Off<br> Object \
Name: <br> Observers: <br> none<br> Pointer: \
0x7f6ef4823010<br> Container manages memory: true<br> Size: \
9699328<br> Capacity: 9699328<br></div><div><br></div></div></div>
The ITK community is transitioning from this mailing list to discourse.itk.org. Please join us there!
________________________________
Powered by www.kitware.com
Visit other Kitware open-source projects at
http://www.kitware.com/opensource/opensource.html
Kitware offers ITK Training Courses, for more information visit:
http://www.kitware.com/products/protraining.php
Please keep messages on-topic and check the ITK FAQ at:
http://www.itk.org/Wiki/ITK_FAQ
Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/insight-users
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic