may I have question about the bUnwarpJ plugin. I already searched over Internet, but not succeed much. I have a case - register two images together, then warp the source image to target image and in the end generate the raw transformation to be able show some important points in the warped image according their positions in source image. (In this moment I don't race much about quality of the registration.) This perfectly works when both image are the same size but in following case the source image is smaller then the target one. Would you have an advice where am I making mistake?
In attachment are two images to be registered together with two list of related points. there is the macro I used for registration, warping image and converting raw transformation and also there is a script that parse the raw transform (as I understood it displacement field for X and Y coordinate) and show the points in image for input source image and warped image.
print ("-> images opening...");
print ("-> start registration...");
+ " registration=Fast image_subsample_factor=1 initial_deformation=[Very Coarse] final_deformation=Fine divergence_weight=0.0 curl_weight=0.0 landmark_weight=0.0 image_weight=1 consistency_weight=10 stop_threshold=0.001 verbose save_transformations "
+ " save_direct_transformation="+
+ " save_inverse_transformation="+
print ("-> registration finished");
// Transform image
im_target, im_source, output+"direct_transform.txt", output+"Rat_Kidney_
// resave image while bunwarpj macro have an issue
// Convert transformation
im_target, im_source, output+"invers_transform.txt", output+"transform_raw.txt");
print ("-> DONE");==============================
import numpy as np
import pandas as pd
import matplotlib.pylab as plt
PATH_IMAGE_REF = 'Rat_Kidney_HE.jpg'
PATH_IMAGE_MOVE = 'Rat_Kidney_PanCytokeratin.
PATH_IMAGE_WARP = 'Rat_Kidney_PanCytokeratin_
PATH_POINTS_MOVE = 'Rat_Kidney_PanCytokeratin.
PATH_POINTS_WARP = 'Rat_Kidney_PanCytokeratin_
PATH_TRANSFORM = 'transform_raw.txt'
def save_landmarks_csv(path_file, landmarks):
df = pd.DataFrame(landmarks, columns=['X', 'Y'])
df = pd.DataFrame.from_csv(path_
points = df[['X', 'Y']].values
width, height = size
points = np.round(points)
selected_lines = points[:, 1].tolist()
pos_new =  * len(points)
# walk thor all lined of this displacement field
for i in range(height):
line = fp.readline()
# if the any point is listed in this line
if i in selected_lines :
pos = line.rstrip().split()
# pos = [float(e) for e in pos if len(e)>0]
assert len(pos) == width
# find all points in this line
for j, point in enumerate(points):
if point == i:
pos_new[j] = float(pos[point])
def load_parse_bunwarpj(path_file, points):
fp = open(path_file, "r")
width = int(fp.readline().split('=')[
height = int(fp.readline().split('=')[
size = (width, height)
assert all(np.max(points, axis=0) <= size)
# read X Trans
points_x = load_parse_bunwarpj_
# read Y Trans
points_y = load_parse_bunwarpj_
points_new = np.array(zip(points_x, points_y))
if __name__ == '__main__':
img_ref = plt.imread(PATH_IMAGE_REF)
img_move = plt.imread(PATH_IMAGE_MOVE)
img_warp = plt.imread(PATH_IMAGE_WARP)
points_move = load_landmarks_csv(PATH_
points_warp = load_parse_bunwarpj(PATH_
plt.plot(points_move[:, 0], points_move[:, 1], 'go')
plt.plot(points_warp[:, 0], points_warp[:, 1], 'go')
ThanksPS: no way how to send the the macro and script as file because it is always automatically rejected
Please avoid top-posting, and please make sure to reply-to-all!
Mailing list web interface: http://groups.google.com/group/fiji-devel
You received this message because you are subscribed to the Google Groups "Fiji-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
|Free forum by Nabble||Edit this page|