Created
September 7, 2012 10:13
-
-
Save miura/3664888 to your computer and use it in GitHub Desktop.
kymograph drift corrector
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Shifts x position of signals in kymograph | |
// in respect to the drifts of egg edge position. | |
// Kota Miura + Masa Mori | |
// | |
// duplicate image (for getting the edge shift) | |
// gaussian blurr (sigma = 1) | |
//threshould | |
// registration in x direction | |
orgID = getImageID(); | |
orgw = getWidth(); | |
orgh = getHeight(); | |
edgeposA = newArray(orgh); | |
for (j = 0; j < orgh; j++){ | |
for (i = 0; i < orgw; i++){ | |
// i = 52; | |
current = getPixel(i, j); | |
if (current == 0) { | |
//print("j:", j, " edge at: x=", i); | |
edgeposA[j] = i; | |
i = orgw; | |
} | |
} | |
} | |
Array.getStatistics(edgeposA, min, max, mean, stdDev); | |
print("min X", min); | |
print("max X", max); | |
newwidth = orgw + (max - min); | |
print("orginal w",orgw); | |
print("new w", newwidth); | |
newImage("shifted", "8-bit Black", newwidth, orgh, 1); | |
shiftedID = getImageID(); | |
setBatchMode(true); | |
for (j = 0; j < orgh; j++){ | |
shiftx = (max - edgeposA[j]); | |
for (i = 0; i < orgw; i++){ | |
selectImage(orgID); | |
curpix = getPixel(i, j); | |
selectImage(shiftedID); | |
newx = i + shiftx; // this is the shift | |
setPixel(newx, j, curpix); | |
} | |
//print("Row:", j); | |
} | |
setBatchMode("exit and display"); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment