久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

SimpleITK 調(diào)整圖像大小

SimpleITK Resize images(SimpleITK 調(diào)整圖像大小)
本文介紹了SimpleITK 調(diào)整圖像大小的處理方法,對大家解決問題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

問題描述

我正在使用 SimpleITK

import SimpleITK as sitk
for filename in filenames:
    image = sitk.ReadImage(filename)

每個(gè)卷都有不同的大小、間距、原點(diǎn)和方向.此代碼為不同的圖像生成不同的值:

Each of the volumes has different size, spacing, origin and direction. This code yields different values for different images:

print(image.GetSize())
print(image.GetOrigin())
print(image.GetSpacing())
print(image.GetDirection())

我的問題是:如何將圖像轉(zhuǎn)換為具有相同的大小和間距,以便在轉(zhuǎn)換為 numpy 數(shù)組時(shí)它們都具有相同的分辨率和大小.比如:

My question is: how do I transform the images to have the same size and spacing so that they all have the same resolution and size when converted to numpy arrays. Something like:

import SimpleITK as sitk
for filename in filenames:
    image = sitk.ReadImage(filename)
    image = transform(image, fixed_size, fixed_spacing)
    array = sitk.GetArrayFromImage(image)

推薦答案

做到這一點(diǎn)的方法是使用具有固定/任意大小和間距的 Resample 函數(shù).下面是一個(gè)代碼片段,展示了這個(gè)reference_image"空間的構(gòu)造:

The way to do this is to use the Resample function with fixed/arbitrary size and spacing. Below is a code snippet showing construction of this "reference_image" space:

reference_origin = np.zeros(dimension)
reference_direction = np.identity(dimension).flatten()
reference_size = [128]*dimension # Arbitrary sizes, smallest size that yields desired results. 
reference_spacing = [ phys_sz/(sz-1) for sz,phys_sz in zip(reference_size, reference_physical_size) ]

reference_image = sitk.Image(reference_size, data[0].GetPixelIDValue())
reference_image.SetOrigin(reference_origin)
reference_image.SetSpacing(reference_spacing)
reference_image.SetDirection(reference_direction)

有關(guān)交鑰匙解決方案,請查看 此 Jupyter 筆記本 說明了如何在 SimpleITK 中使用可變大小的圖像進(jìn)行數(shù)據(jù)增強(qiáng)(上面的代碼來自筆記本).您也可以從 SimpleITK 筆記本存儲庫 中找到其他可用的筆記本.

For a turnkey solution have a look at this Jupyter notebook which illustrates how to do data augmentation with variable sized images in SimpleITK (code above is from the notebook). You may find the other notebooks from the SimpleITK notebook repository of use too.

這篇關(guān)于SimpleITK 調(diào)整圖像大小的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請聯(lián)系我們刪除處理,感謝您的支持!

相關(guān)文檔推薦

How to draw a rectangle around a region of interest in python(如何在python中的感興趣區(qū)域周圍繪制一個(gè)矩形)
How can I detect and track people using OpenCV?(如何使用 OpenCV 檢測和跟蹤人員?)
How to apply threshold within multiple rectangular bounding boxes in an image?(如何在圖像的多個(gè)矩形邊界框中應(yīng)用閾值?)
How can I download a specific part of Coco Dataset?(如何下載 Coco Dataset 的特定部分?)
Detect image orientation angle based on text direction(根據(jù)文本方向檢測圖像方向角度)
Detect centre and angle of rectangles in an image using Opencv(使用 Opencv 檢測圖像中矩形的中心和角度)
主站蜘蛛池模板: 在线午夜电影 | 欧美成人手机在线 | 黑人巨大精品欧美一区二区免费 | 国产精品久久久久久238 | 中文字幕av一区 | 韩日在线视频 | 91视频在线观看 | 毛片网站在线观看 | 黑人精品欧美一区二区蜜桃 | 午夜影院网站 | 久久九精品 | 成人精品鲁一区一区二区 | 精品一区二区在线观看 | 91视频播放| 99久久精品国产一区二区三区 | 在线观看中文字幕视频 | 99re6在线视频 | 亚洲欧美一区二区三区国产精品 | 亚洲福利片 | 日日摸日日添日日躁av | 男人视频网站 | 91免费观看国产 | 国产精品18久久久久久白浆动漫 | 久久精品亚洲精品国产欧美 | 怡红院怡春院一级毛片 | 久久亚洲一区二区三区四区 | 在线不卡av| 欧美一级免费看 | 精品欧美一区二区在线观看欧美熟 | 久久久久久免费毛片精品 | 一区二区国产精品 | 成人免费观看男女羞羞视频 | h在线免费观看 | 日韩成人在线电影 | 国产精品一区在线观看 | 欧美videosex性极品hd | 久久精品无码一区二区三区 | 久久久国产一区二区 | 亚洲精品一区二三区不卡 | 九九热视频这里只有精品 | 亚洲电影一区 |