如何转换超声图像以模拟 CT 图像?

问题描述

所以我想使用 GAN 从超声图像模拟 CT 图像,我目前正在准备数据。

根据超声波的性质,这些图像以锥形形式存储:

enter image description here

但我想要的是以下形式的图像:

enter image description here

我相信这样更容易模拟 CT 图像。

我使用的是简单的 ITK。我想这应该是一个常见的转变。 是否有我不知道的来自 sITK 的过滤器?或者有没有其他简单的方法来进行这种转换?

解决方法

单应性的想法不起作用,所以这不会作为答案,但希望其中一些仍然有帮助。

我基本上针对六个关键点并试图纠正它们。然而,单应性没有处理顶部和底部的圆柱曲线。

enter image description here

import cv2
import numpy as np

# load image
img = cv2.imread("original.png");

# chop bottom (there's a weird gray band down there)
h,w = img.shape[:2];
img = img[:h-10,:,:];

# convert color
gray = cv2.cvtColor(img,cv2.COLOR_BGR2GRAY);
thresh = cv2.inRange(gray,30,255);

# split
h,w = gray.shape;
half = int(w/2);
left = gray[:,:half];
right = gray[:,half:];

# find corners
threshold = 30;
# top left
stop = False;
tl = [-1,-1];
for y in range(h):
    for x in range(half):
        if left[y,x] > threshold:
            tl = [x,y];
            stop = True;
            break;
    if stop:
        break;

# top right
stop = False;
tr = [-1,-1];
for y in range(h):
    for x in range(half):
        if right[y,x] > threshold:
            tr = [x + half,y];
            stop = True;
            break;
    if stop:
        break;

# bottom left
bl = [-1,-1];
stop = False;
for x in range(half):
    for y in range(h):
        if left[y,x] > threshold:
            bl = [x,y];
            stop = True;
            break;
    if stop:
        break;

# bottom right
br = [-1,-1];
stop = False;
for x in range(half - 1,-1):
    for y in range(h):
        if right[y,x] > threshold:
            br = [x + half,y];
            stop = True;
            break;
    if stop:
        break;

# middle top
mt = [-1,-1];
for y in range(h):
    if right[y,0] > threshold:
        mt = [half,y];

# middle bottom
mb = [-1,-1];
for y in range(h-1,-1):
    if right[y,0] > threshold:
        mb = [half,y];


# corners
corners = [];
corners.append(tl);
corners.append(tr);
corners.append(br);
corners.append(bl);
corners.append(mt);
corners.append(mb);

# draw points
for p in corners:
    print(p);
    tup = (p[0],p[1]);
    img = cv2.circle(img,tup,10,(0,255),-1);
# img = cv2.circle(img,(100,100),1000,-1);
print("Res: " + str([w,h]));

# create homography destination
targets = [];
targets.append([0,0]); # tl
targets.append([w,0]); # tr
targets.append([w,h]); # br
targets.append([0,h]); # bl
targets.append([half,0]); # mt
targets.append([half,h]); # mb

# make blank
corners = np.array(corners);
targets = np.array(targets);
hmat,ret = cv2.findHomography(corners,targets);

# warp image
warped = cv2.warpPerspective(img,hmat,(w,h));

# show
cv2.imshow("img",img);
cv2.imshow("thresh",thresh);
cv2.imshow("warped",warped);
cv2.waitKey(0);