Modifying A Large Number Of DICOM (.dcm) Files.
bit of a simple question perhaps but I am not making progress and would appreciate help.
I have a list of size 422. Within index 0 there are 135 file paths to .dcm images. For example '~/images/0001.dcm','~/images/0135.dcm' Within index 1, there are 112 image paths, index 2 has 110, etc.
All images are of size 512 x 512. I am looking to re-size them to be 64 x 64.
This is my first time working with both image and .dcm data so I'm very unsure about how to resize. I am also unsure how to access and modify the files within the 'inner' list, if you will.
Is something like this way off the mark?
IMG_PX_SIZE = 64 result =  for i in test_list: result_inner_list =  for image in i: # resize all images at index position i and store in list new_img = cv2.resize(np.array(image.pixel_array (IMG_PX_SIZE,IMG_PX_SIZE)) result_inner_list.append(new_img) # Once all images at index point i are modified, append them these to a master list. result.append(result_inner_list)
You seem to be struggling with two issues:
- accessing the file paths
For you to win, better separate these two tasks, sample code below
IMG_PX_SIZE = 64 def resize(image): # your resize code here similar to: # return v2.resize(np.array(image.pixel_array(IMG_PX_SIZE,IMG_PX_SIZE)) pass def read(path): # your file read operation here pass big_list = [['~/images/0001.dcm','~/images/0135.dcm'], ['~/images/0002.dcm','~/images/0136.dcm']] resized_images = [[resize(read(path)) for path in paths] for paths in big_list]
- → What are the pluses/minuses of different ways to configure GPIOs on the Beaglebone Black?
- → Django, code inside <script> tag doesn't work in a template
- → React - Django webpack config with dynamic 'output'
- → GAE Python app - Does URL matter for SEO?
- → Put a Rendered Django Template in Json along with some other items
- → session disappears when request is sent from fetch
- → Python Shopify API output formatted datetime string in django template
- → Shopify app: adding a new shipping address via webhook
- → Shopify + Python library: how to create new shipping address
- → shopify python api: how do add new assets to published theme?
- → Access 'HTTP_X_SHOPIFY_SHOP_API_CALL_LIMIT' with Python Shopify Module