2024-05-17 06:31:26 发布
网友
所以我想用GAN模拟超声图像的CT图像,我目前正在准备数据
根据超声波的性质,这些图像以锥形形式存储:
但我想要的是以下形式的图像:
我相信这样模拟CT图像更容易
我正在使用简单的ITK。我想这应该是一种常见的转变。 有没有我不知道的sITK的过滤器?或者有没有其他简单的方法来实现这种转换
单应性的想法不起作用,所以这不会作为一个答案,但希望其中一些仍然有用
我基本上瞄准了六个关键点,并试图纠正它们。然而,单应性不能处理顶部和底部的圆柱形曲线
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, 0, -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, 0, -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,0,255), -1); # img = cv2.circle(img, (100, 100), 1000, (0, 0, 255), -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);
单应性的想法不起作用,所以这不会作为一个答案,但希望其中一些仍然有用
我基本上瞄准了六个关键点,并试图纠正它们。然而,单应性不能处理顶部和底部的圆柱形曲线
相关问题 更多 >
编程相关推荐