-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexport_pixels.m
30 lines (25 loc) · 1.21 KB
/
export_pixels.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
function done = export_pixels(folder, imageObj)
%EXPORT_PIXELS Outputs the position of pixels to csv/tsv files
% To calculate the stiffness of the DNA molecules, specific data formats
% are required by the appropriate program.
% To ensure the compatibility, the user may enable or disable to
% conversion to the absolute image position (depending on the scansize of
% the original image).
global PIXELLENGTH EXPORTREAL EXPORTONLYVALID;
dnaCount = size(imageObj.dnaList,2);
for i = 1:dnaCount
if ((EXPORTONLYVALID == 1 && imageObj.dnaList{i}.isValid ==1) || (EXPORTONLYVALID == 0))
[x,y] = ind2sub(imageObj.dnaList{i}.sizeImg, imageObj.dnaList{i}.connectedThinnedRemoved);
if (EXPORTREAL==1)
x = round(x*PIXELLENGTH, 6);
y = round(y*PIXELLENGTH, 6);
end
output = table(x,y);
% enable the upper line for format 001,002,..., lower for 1,2,...
%temp = [folder 'file' num2str(i, '%03i') '.txt'];
temp = fullfile (folder, ['file' num2str(i) '.txt']);
writetable(output, temp, 'delimiter', ' ', 'WriteVariableNames', 0)
end
end
done = 'done';
end