Image Representation conversion to functional array
I want to be able to convert a set of image representations of wing venation patterns to a multiple array format.
For each wing vein, the array needs to include
L, h = xy coordinate for the start of the vein
vt = the thickness of the vein
Lf, hf = xy coordinate for the end of the vein
R = rough aggregate radius of the arc of the vein.
For each cross-vein, the array needs to include
L1% = the starting x position of the connecting cross-vein
L2% = the finishing x position of the connecting cross-vein
ct = thickness of the cross vein
The total array is about 69 values long with it being split into a 7×6 and 3×9 array for vein and cross-vein properties respectively.
I’ve had some success with the reverse of this (taking an encoded array and converting that into an image representation, attached below with an example of one of the images that will be used).
%% Define the vein and cross_vein arrays
asydentus.vein = [1.25 25 2 92.5 29.5 39.47041396 ; 2.25 27.5 3 43.75 16.5 -14.73949649 ; 13.75 29.5 1 71.25 21 -33.2551027 ; 13.75 29.5 1 86.75 26.5 -79.65111699 ; 10 37.5 2 74.5 58.5 43.17494694 ; 10 37.5 2 63 93 17.18991587 ; 10 37.5 1 25 72.5 4.144372635];
asydentus.cross_vein = [13.25 15 2 ; 0 0 0 ; 0 0 0 ; 25.25 26.75 2 ; 30.75 30.5 2 ; 20.5 19.25 2 ; 0 0 0 ; 0 0 0 ; 0 0 0];
% Scaling factors
sf1 = 4;
sf2 = -2;
sf3 = 20;
%% Define startpoints and endpoints for veins and cross-veins and define radius for veins
vein1.p1 = [sf1 * asydentus.vein(1,1), sf2 * asydentus.vein(1,2)]; % vein 1 startpoint
vein1.p2 = [sf1 * asydentus.vein(1,4), sf2 * asydentus.vein(1,5)]; % vein 1 endpoint
vein1.r = sf3 * [asydentus.vein(1,6)]; % vein 1 radius value
vein2.p1 = [sf1 * asydentus.vein(2,1), sf2 * asydentus.vein(2,2)]; % vein 2 startpoint
vein2.p2 = [sf1 * asydentus.vein(2,4), sf2 * asydentus.vein(2,5)]; % vein 2 endpoint
vein2.r = sf3 * [asydentus.vein(2,6)]; % vein 2 radius value
vein3.p1 = [sf1 * asydentus.vein(3,1), sf2 * asydentus.vein(3,2)]; % vein 3 startpoint
vein3.p2 = [sf1 * asydentus.vein(3,4), sf2 * asydentus.vein(3,5)]; % vein 3 endpoint
vein3.r = sf3 * [asydentus.vein(3,6)]; % vein 3 radius value
vein4.p1 = [sf1 * asydentus.vein(4,1), sf2 * asydentus.vein(4,2)]; % vein 4 startpoint
vein4.p2 = [sf1 * asydentus.vein(4,4), sf2 * asydentus.vein(4,5)]; % vein 4 endpoint
vein4.r = sf3 * [asydentus.vein(4,6)]; % vein 4 radius value
vein5.p1 = [sf1 * asydentus.vein(5,1), sf2 * asydentus.vein(5,2)]; % vein 5 startpoint
vein5.p2 = [sf1 * asydentus.vein(5,4), sf2 * asydentus.vein(5,5)]; % vein 5 endpoint
vein5.r = sf3 * [asydentus.vein(5,6)]; % vein 5 radius value
vein6.p1 = [sf1 * asydentus.vein(6,1), sf2 * asydentus.vein(6,2)]; % vein 6 startpoint
vein6.p2 = [sf1 * asydentus.vein(6,4), sf2 * asydentus.vein(6,5)]; % vein 6 endpoint
vein6.r = sf3 * [asydentus.vein(6,6)]; % vein 6 radius value
vein7.p1 = [sf1 * asydentus.vein(7,1), sf2 * asydentus.vein(7,2)]; % vein 7 startpoint
vein7.p2 = [sf1 * asydentus.vein(7,4), sf2 * asydentus.vein(7,5)]; % vein 7 endpoint
vein7.r = sf3 * [asydentus.vein(7,6)]; % vein 7 radius value
crossvein1.x1 = sf1 * [asydentus.cross_vein(1,1)]; % crossvein 1 start x-coordinate
crossvein1.x2 = sf1 * [asydentus.cross_vein(1,2)]; % crossvein 1 end x-coordinate
crossvein4.x1 = sf1 * [asydentus.cross_vein(4,1)]; % crossvein 4 start x-coordinate
crossvein4.x2 = sf1 * [asydentus.cross_vein(4,2)]; % crossvein 4 end x-coordinate
crossvein5.x1 = sf1 * [asydentus.cross_vein(5,1)]; % crossvein 5 start x-coordinate
crossvein5.x2 = sf1 * [asydentus.cross_vein(5,2)]; % crossvein 5 end x-coordinate
crossvein6.x1 = sf1 * [asydentus.cross_vein(6,1)]; % crossvein 6 start x-coordinate
crossvein6.x2 = sf1 * [asydentus.cross_vein(6,1)]; % crossvein 6 end x-coordinate
%% Solve for centre of radius and cross-vein coordinates
syms x1 y1
[x1, y1] = solve((x1-vein1.p1(1))^2+(y1-vein1.p1(2))^2==vein1.r^2, (x1-vein1.p2(1))^2+(y1-vein1.p2(2))^2==vein1.r^2, x1, y1);
% vein 1 centre of radius
arc1_c1 = double([x1(1), y1(1)]);
arc1_c2 = double([x1(2), y1(2)]);
syms x2 y2
[x2, y2] = solve((x2-vein2.p1(1))^2+(y2-vein2.p1(2))^2==vein2.r^2, (x2-vein2.p2(1))^2+(y2-vein2.p2(2))^2==vein2.r^2, x2, y2);
% vein 2 centre of radius
arc2_c1 = double([x2(1), y2(1)]);
arc2_c2 = double([x2(2), y2(2)]);
syms x3 y3
[x3, y3] = solve((x3-vein3.p1(1))^2+(y3-vein3.p1(2))^2==vein3.r^2, (x3-vein3.p2(1))^2+(y3-vein3.p2(2))^2==vein3.r^2, x3, y3);
% vein 3 centre of radius
arc3_c1 = double([x3(1), y3(1)]);
arc3_c2 = double([x3(2), y3(2)]);
syms x4 y4
[x4, y4] = solve((x4-vein4.p1(1))^2+(y4-vein4.p1(2))^2==vein4.r^2, (x4-vein4.p2(1))^2+(y4-vein4.p2(2))^2==vein4.r^2, x4, y4);
% vein 4 centre of radius
arc4_c1 = double([x4(1), y4(1)]);
arc4_c2 = double([x4(2), y4(2)]);
syms x5 y5
[x5, y5] = solve((x5-vein5.p1(1))^2+(y5-vein5.p1(2))^2==vein5.r^2, (x5-vein5.p2(1))^2+(y5-vein5.p2(2))^2==vein5.r^2, x5, y5);
% vein 5 centre of radius
arc5_c1 = double([x5(1), y5(1)]);
arc5_c2 = double([x5(2), y5(2)]);
syms x6 y6
[x6, y6] = solve((x6-vein6.p1(1))^2+(y6-vein6.p1(2))^2==vein6.r^2, (x6-vein6.p2(1))^2+(y6-vein6.p2(2))^2==vein6.r^2, x6, y6);
% vein 6 centre of radius
arc6_c1 = double([x6(1), y6(1)]);
arc6_c2 = double([x6(2), y6(2)]);
syms x7 y7
[x7, y7] = solve((x7-vein7.p1(1))^2+(y7-vein7.p1(2))^2==vein7.r^2, (x7-vein7.p2(1))^2+(y7-vein7.p2(2))^2==vein7.r^2, x7, y7);
% vein 7 centre of radius
arc7_c1 = double([x7(1), y7(1)]);
arc7_c2 = double([x7(2), y7(2)]);
syms yc1_1
[yc1_1] = solve ((crossvein1.x1(1) – arc1_c1(1)).^2 + (yc1_1 – arc1_c1(2)).^2 – vein1.r^2, (-200<=yc1_1)<=0);
crossvein1.y1 = yc1_1;
syms yc1_2
[yc1_2] = solve ((crossvein1.x2(1) – arc2_c2(1)).^2 + (yc1_2 – arc2_c2(2)).^2 – vein2.r^2, (-200<=yc1_2)<=0);
crossvein1.y2 = yc1_2;
syms yc4_1
[yc4_1] = solve ((crossvein4.x1(1) – arc4_c2(1)).^2 + (yc4_1 – arc4_c2(2)).^2 – vein4.r^2, (-200<=yc4_1)<=0);
crossvein4.y1 = yc4_1;
syms yc4_2
[yc4_2] = solve ((crossvein4.x2(1) – arc5_c1(1)).^2 + (yc4_2 – arc5_c1(2)).^2 – vein5.r^2, (-200<=yc4_2)<=0);
crossvein4.y2 = yc4_2;
syms yc5_1
[yc5_1] = solve ((crossvein5.x1(1) – arc5_c1(1)).^2 + (yc5_1 – arc5_c1(2)).^2 – vein5.r^2, (-200<=yc5_1)<=0);
crossvein5.y1 = yc5_1;
syms yc5_2
[yc5_2] = solve ((crossvein5.x2(1) – arc6_c1(1)).^2 + (yc5_2 – arc6_c1(2)).^2 – vein6.r^2, (-200<=yc5_2)<=0);
crossvein5.y2 = yc5_2;
syms yc6_1
[yc6_1] = solve ((crossvein6.x1(1) – arc6_c1(1)).^2 + (yc6_1 – arc6_c1(2)).^2 – vein6.r^2, (-200<=yc6_1)<=0);
crossvein6.y1 = yc6_1;
syms yc6_2
[yc6_2] = solve ((crossvein6.x2(1) – arc7_c1(1)).^2 + (yc6_2 – arc7_c1(2)).^2 – vein7.r^2, (-200<=yc6_2)<=0);
crossvein6.y2 = yc6_2;
%% Define Arc Function for vein radius
figure;
hold on;
% Define the implicit functions for the circles
f1_1 = @(X1, Y1) (X1 – arc1_c1(1)).^2 + (Y1 – arc1_c1(2)).^2 – vein1.r^2;
f1_2 = @(X1, Y1) (X1 – arc1_c2(1)).^2 + (Y1 – arc1_c2(2)).^2 – vein1.r^2;
f2_1 = @(X2, Y2) (X2 – arc2_c1(1)).^2 + (Y2 – arc2_c1(2)).^2 – vein2.r^2;
f2_2 = @(X2, Y2) (X2 – arc2_c2(1)).^2 + (Y2 – arc2_c2(2)).^2 – vein2.r^2;
f3_1 = @(X3, Y3) (X3 – arc3_c1(1)).^2 + (Y3 – arc3_c1(2)).^2 – vein3.r^2;
f3_2 = @(X3, Y3) (X3 – arc3_c2(1)).^2 + (Y3 – arc3_c2(2)).^2 – vein3.r^2;
f4_1 = @(X4, Y4) (X4 – arc4_c1(1)).^2 + (Y4 – arc4_c1(2)).^2 – vein4.r^2;
f4_2 = @(X4, Y4) (X4 – arc4_c2(1)).^2 + (Y4 – arc4_c2(2)).^2 – vein4.r^2;
f5_1 = @(X5, Y5) (X5 – arc5_c1(1)).^2 + (Y5 – arc5_c1(2)).^2 – vein5.r^2;
f5_2 = @(X5, Y5) (X5 – arc5_c2(1)).^2 + (Y5 – arc5_c2(2)).^2 – vein5.r^2;
f6_1 = @(X6, Y6) (X6 – arc6_c1(1)).^2 + (Y6 – arc6_c1(2)).^2 – vein6.r^2;
f6_2 = @(X6, Y6) (X6 – arc6_c2(1)).^2 + (Y6 – arc6_c2(2)).^2 – vein6.r^2;
f7_1 = @(X7, Y7) (X7 – arc7_c1(1)).^2 + (Y7 – arc7_c1(2)).^2 – vein7.r^2;
f7_2 = @(X7, Y7) (X7 – arc7_c2(1)).^2 + (Y7 – arc7_c2(2)).^2 – vein7.r^2;
%% Plot the veins and cross-veins using fimplicit
% Depending on whether the arc of the vein is 0<=180 or 180<=360 will
% decide which implicit function is used
% use image representations as a guide
t = [1; 2; 3]; % Line Thickness
fimplicit(f1_1, [5 370 -200 0], ‘LineWidth’, t(2) , ‘Color’, ‘k’); % Adjust LineWidth as needed, matrix within fimplicit is made
%fimplicit(f1_2, [5 370 -200 0], ‘LineWidth’, t(2) , ‘Color’, ‘k’); % Adjust LineWidth as needed
%fimplicit(f2_1, [9 175 -200 0], ‘LineWidth’, t(3) , ‘Color’, ‘k’); % Adjust LineWidth as needed, matrix within fimplicit is made
fimplicit(f2_2, [9 175 -200 0], ‘LineWidth’, t(3) , ‘Color’, ‘k’); % Adjust LineWidth as needed
%fimplicit(f3_1, [55 285 -200 0], ‘LineWidth’, t(1) , ‘Color’, ‘k’); % Adjust LineWidth as needed, matrix within fimplicit is made
fimplicit(f3_2, [55 285 -200 0], ‘LineWidth’, t(1) , ‘Color’, ‘k’); % Adjust LineWidth as needed
%fimplicit(f4_1, [55 347 -200 0], ‘LineWidth’, t(1) , ‘Color’, ‘k’); % Adjust LineWidth as needed, matrix within fimplicit is made
fimplicit(f4_2, [55 347 -200 0], ‘LineWidth’, t(1) , ‘Color’, ‘k’); % Adjust LineWidth as needed
fimplicit(f5_1, [40 298 -200 0], ‘LineWidth’, t(2) , ‘Color’, ‘k’); % Adjust LineWidth as needed, matrix within fimplicit is made
%fimplicit(f5_2, [40 298 -200 0], ‘LineWidth’, t(2) , ‘Color’, ‘k’); % Adjust LineWidth as needed
fimplicit(f6_1, [40 252 -200 0], ‘LineWidth’, t(2) , ‘Color’, ‘k’); % Adjust LineWidth as needed, matrix within fimplicit is made
%fimplicit(f6_2, [40 252 -200 0], ‘LineWidth’, t(2) , ‘Color’, ‘k’); % Adjust LineWidth as needed
fimplicit(f7_1, [40 100 -160 0], ‘LineWidth’, t(1) , ‘Color’, ‘k’); % Adjust LineWidth as needed, matrix within fimplicit is made
%fimplicit(f7_2, [40 100 -160 0], ‘LineWidth’, t(1) , ‘Color’, ‘k’); % Adjust LineWidth as needed
plot([crossvein1.x1 crossvein1.x2], [crossvein1.y1 crossvein1.y2], ‘LineWidth’,t(2), ‘Color’, ‘r’)
plot([crossvein4.x1 crossvein4.x2], [crossvein4.y1 crossvein4.y2], ‘LineWidth’,t(2), ‘Color’, ‘r’)
plot([crossvein5.x1 crossvein5.x2], [crossvein5.y1 crossvein5.y2], ‘LineWidth’,t(2), ‘Color’, ‘r’)
plot([crossvein6.x1 crossvein6.x2], [crossvein6.y1 crossvein6.y2], ‘LineWidth’,t(2), ‘Color’, ‘r’)
% Plot settings
axis([0 400 -200 0]);
xlabel(‘X’);
ylabel(‘Y’);
title(‘Asydentus Venation’);
hold off;I want to be able to convert a set of image representations of wing venation patterns to a multiple array format.
For each wing vein, the array needs to include
L, h = xy coordinate for the start of the vein
vt = the thickness of the vein
Lf, hf = xy coordinate for the end of the vein
R = rough aggregate radius of the arc of the vein.
For each cross-vein, the array needs to include
L1% = the starting x position of the connecting cross-vein
L2% = the finishing x position of the connecting cross-vein
ct = thickness of the cross vein
The total array is about 69 values long with it being split into a 7×6 and 3×9 array for vein and cross-vein properties respectively.
I’ve had some success with the reverse of this (taking an encoded array and converting that into an image representation, attached below with an example of one of the images that will be used).
%% Define the vein and cross_vein arrays
asydentus.vein = [1.25 25 2 92.5 29.5 39.47041396 ; 2.25 27.5 3 43.75 16.5 -14.73949649 ; 13.75 29.5 1 71.25 21 -33.2551027 ; 13.75 29.5 1 86.75 26.5 -79.65111699 ; 10 37.5 2 74.5 58.5 43.17494694 ; 10 37.5 2 63 93 17.18991587 ; 10 37.5 1 25 72.5 4.144372635];
asydentus.cross_vein = [13.25 15 2 ; 0 0 0 ; 0 0 0 ; 25.25 26.75 2 ; 30.75 30.5 2 ; 20.5 19.25 2 ; 0 0 0 ; 0 0 0 ; 0 0 0];
% Scaling factors
sf1 = 4;
sf2 = -2;
sf3 = 20;
%% Define startpoints and endpoints for veins and cross-veins and define radius for veins
vein1.p1 = [sf1 * asydentus.vein(1,1), sf2 * asydentus.vein(1,2)]; % vein 1 startpoint
vein1.p2 = [sf1 * asydentus.vein(1,4), sf2 * asydentus.vein(1,5)]; % vein 1 endpoint
vein1.r = sf3 * [asydentus.vein(1,6)]; % vein 1 radius value
vein2.p1 = [sf1 * asydentus.vein(2,1), sf2 * asydentus.vein(2,2)]; % vein 2 startpoint
vein2.p2 = [sf1 * asydentus.vein(2,4), sf2 * asydentus.vein(2,5)]; % vein 2 endpoint
vein2.r = sf3 * [asydentus.vein(2,6)]; % vein 2 radius value
vein3.p1 = [sf1 * asydentus.vein(3,1), sf2 * asydentus.vein(3,2)]; % vein 3 startpoint
vein3.p2 = [sf1 * asydentus.vein(3,4), sf2 * asydentus.vein(3,5)]; % vein 3 endpoint
vein3.r = sf3 * [asydentus.vein(3,6)]; % vein 3 radius value
vein4.p1 = [sf1 * asydentus.vein(4,1), sf2 * asydentus.vein(4,2)]; % vein 4 startpoint
vein4.p2 = [sf1 * asydentus.vein(4,4), sf2 * asydentus.vein(4,5)]; % vein 4 endpoint
vein4.r = sf3 * [asydentus.vein(4,6)]; % vein 4 radius value
vein5.p1 = [sf1 * asydentus.vein(5,1), sf2 * asydentus.vein(5,2)]; % vein 5 startpoint
vein5.p2 = [sf1 * asydentus.vein(5,4), sf2 * asydentus.vein(5,5)]; % vein 5 endpoint
vein5.r = sf3 * [asydentus.vein(5,6)]; % vein 5 radius value
vein6.p1 = [sf1 * asydentus.vein(6,1), sf2 * asydentus.vein(6,2)]; % vein 6 startpoint
vein6.p2 = [sf1 * asydentus.vein(6,4), sf2 * asydentus.vein(6,5)]; % vein 6 endpoint
vein6.r = sf3 * [asydentus.vein(6,6)]; % vein 6 radius value
vein7.p1 = [sf1 * asydentus.vein(7,1), sf2 * asydentus.vein(7,2)]; % vein 7 startpoint
vein7.p2 = [sf1 * asydentus.vein(7,4), sf2 * asydentus.vein(7,5)]; % vein 7 endpoint
vein7.r = sf3 * [asydentus.vein(7,6)]; % vein 7 radius value
crossvein1.x1 = sf1 * [asydentus.cross_vein(1,1)]; % crossvein 1 start x-coordinate
crossvein1.x2 = sf1 * [asydentus.cross_vein(1,2)]; % crossvein 1 end x-coordinate
crossvein4.x1 = sf1 * [asydentus.cross_vein(4,1)]; % crossvein 4 start x-coordinate
crossvein4.x2 = sf1 * [asydentus.cross_vein(4,2)]; % crossvein 4 end x-coordinate
crossvein5.x1 = sf1 * [asydentus.cross_vein(5,1)]; % crossvein 5 start x-coordinate
crossvein5.x2 = sf1 * [asydentus.cross_vein(5,2)]; % crossvein 5 end x-coordinate
crossvein6.x1 = sf1 * [asydentus.cross_vein(6,1)]; % crossvein 6 start x-coordinate
crossvein6.x2 = sf1 * [asydentus.cross_vein(6,1)]; % crossvein 6 end x-coordinate
%% Solve for centre of radius and cross-vein coordinates
syms x1 y1
[x1, y1] = solve((x1-vein1.p1(1))^2+(y1-vein1.p1(2))^2==vein1.r^2, (x1-vein1.p2(1))^2+(y1-vein1.p2(2))^2==vein1.r^2, x1, y1);
% vein 1 centre of radius
arc1_c1 = double([x1(1), y1(1)]);
arc1_c2 = double([x1(2), y1(2)]);
syms x2 y2
[x2, y2] = solve((x2-vein2.p1(1))^2+(y2-vein2.p1(2))^2==vein2.r^2, (x2-vein2.p2(1))^2+(y2-vein2.p2(2))^2==vein2.r^2, x2, y2);
% vein 2 centre of radius
arc2_c1 = double([x2(1), y2(1)]);
arc2_c2 = double([x2(2), y2(2)]);
syms x3 y3
[x3, y3] = solve((x3-vein3.p1(1))^2+(y3-vein3.p1(2))^2==vein3.r^2, (x3-vein3.p2(1))^2+(y3-vein3.p2(2))^2==vein3.r^2, x3, y3);
% vein 3 centre of radius
arc3_c1 = double([x3(1), y3(1)]);
arc3_c2 = double([x3(2), y3(2)]);
syms x4 y4
[x4, y4] = solve((x4-vein4.p1(1))^2+(y4-vein4.p1(2))^2==vein4.r^2, (x4-vein4.p2(1))^2+(y4-vein4.p2(2))^2==vein4.r^2, x4, y4);
% vein 4 centre of radius
arc4_c1 = double([x4(1), y4(1)]);
arc4_c2 = double([x4(2), y4(2)]);
syms x5 y5
[x5, y5] = solve((x5-vein5.p1(1))^2+(y5-vein5.p1(2))^2==vein5.r^2, (x5-vein5.p2(1))^2+(y5-vein5.p2(2))^2==vein5.r^2, x5, y5);
% vein 5 centre of radius
arc5_c1 = double([x5(1), y5(1)]);
arc5_c2 = double([x5(2), y5(2)]);
syms x6 y6
[x6, y6] = solve((x6-vein6.p1(1))^2+(y6-vein6.p1(2))^2==vein6.r^2, (x6-vein6.p2(1))^2+(y6-vein6.p2(2))^2==vein6.r^2, x6, y6);
% vein 6 centre of radius
arc6_c1 = double([x6(1), y6(1)]);
arc6_c2 = double([x6(2), y6(2)]);
syms x7 y7
[x7, y7] = solve((x7-vein7.p1(1))^2+(y7-vein7.p1(2))^2==vein7.r^2, (x7-vein7.p2(1))^2+(y7-vein7.p2(2))^2==vein7.r^2, x7, y7);
% vein 7 centre of radius
arc7_c1 = double([x7(1), y7(1)]);
arc7_c2 = double([x7(2), y7(2)]);
syms yc1_1
[yc1_1] = solve ((crossvein1.x1(1) – arc1_c1(1)).^2 + (yc1_1 – arc1_c1(2)).^2 – vein1.r^2, (-200<=yc1_1)<=0);
crossvein1.y1 = yc1_1;
syms yc1_2
[yc1_2] = solve ((crossvein1.x2(1) – arc2_c2(1)).^2 + (yc1_2 – arc2_c2(2)).^2 – vein2.r^2, (-200<=yc1_2)<=0);
crossvein1.y2 = yc1_2;
syms yc4_1
[yc4_1] = solve ((crossvein4.x1(1) – arc4_c2(1)).^2 + (yc4_1 – arc4_c2(2)).^2 – vein4.r^2, (-200<=yc4_1)<=0);
crossvein4.y1 = yc4_1;
syms yc4_2
[yc4_2] = solve ((crossvein4.x2(1) – arc5_c1(1)).^2 + (yc4_2 – arc5_c1(2)).^2 – vein5.r^2, (-200<=yc4_2)<=0);
crossvein4.y2 = yc4_2;
syms yc5_1
[yc5_1] = solve ((crossvein5.x1(1) – arc5_c1(1)).^2 + (yc5_1 – arc5_c1(2)).^2 – vein5.r^2, (-200<=yc5_1)<=0);
crossvein5.y1 = yc5_1;
syms yc5_2
[yc5_2] = solve ((crossvein5.x2(1) – arc6_c1(1)).^2 + (yc5_2 – arc6_c1(2)).^2 – vein6.r^2, (-200<=yc5_2)<=0);
crossvein5.y2 = yc5_2;
syms yc6_1
[yc6_1] = solve ((crossvein6.x1(1) – arc6_c1(1)).^2 + (yc6_1 – arc6_c1(2)).^2 – vein6.r^2, (-200<=yc6_1)<=0);
crossvein6.y1 = yc6_1;
syms yc6_2
[yc6_2] = solve ((crossvein6.x2(1) – arc7_c1(1)).^2 + (yc6_2 – arc7_c1(2)).^2 – vein7.r^2, (-200<=yc6_2)<=0);
crossvein6.y2 = yc6_2;
%% Define Arc Function for vein radius
figure;
hold on;
% Define the implicit functions for the circles
f1_1 = @(X1, Y1) (X1 – arc1_c1(1)).^2 + (Y1 – arc1_c1(2)).^2 – vein1.r^2;
f1_2 = @(X1, Y1) (X1 – arc1_c2(1)).^2 + (Y1 – arc1_c2(2)).^2 – vein1.r^2;
f2_1 = @(X2, Y2) (X2 – arc2_c1(1)).^2 + (Y2 – arc2_c1(2)).^2 – vein2.r^2;
f2_2 = @(X2, Y2) (X2 – arc2_c2(1)).^2 + (Y2 – arc2_c2(2)).^2 – vein2.r^2;
f3_1 = @(X3, Y3) (X3 – arc3_c1(1)).^2 + (Y3 – arc3_c1(2)).^2 – vein3.r^2;
f3_2 = @(X3, Y3) (X3 – arc3_c2(1)).^2 + (Y3 – arc3_c2(2)).^2 – vein3.r^2;
f4_1 = @(X4, Y4) (X4 – arc4_c1(1)).^2 + (Y4 – arc4_c1(2)).^2 – vein4.r^2;
f4_2 = @(X4, Y4) (X4 – arc4_c2(1)).^2 + (Y4 – arc4_c2(2)).^2 – vein4.r^2;
f5_1 = @(X5, Y5) (X5 – arc5_c1(1)).^2 + (Y5 – arc5_c1(2)).^2 – vein5.r^2;
f5_2 = @(X5, Y5) (X5 – arc5_c2(1)).^2 + (Y5 – arc5_c2(2)).^2 – vein5.r^2;
f6_1 = @(X6, Y6) (X6 – arc6_c1(1)).^2 + (Y6 – arc6_c1(2)).^2 – vein6.r^2;
f6_2 = @(X6, Y6) (X6 – arc6_c2(1)).^2 + (Y6 – arc6_c2(2)).^2 – vein6.r^2;
f7_1 = @(X7, Y7) (X7 – arc7_c1(1)).^2 + (Y7 – arc7_c1(2)).^2 – vein7.r^2;
f7_2 = @(X7, Y7) (X7 – arc7_c2(1)).^2 + (Y7 – arc7_c2(2)).^2 – vein7.r^2;
%% Plot the veins and cross-veins using fimplicit
% Depending on whether the arc of the vein is 0<=180 or 180<=360 will
% decide which implicit function is used
% use image representations as a guide
t = [1; 2; 3]; % Line Thickness
fimplicit(f1_1, [5 370 -200 0], ‘LineWidth’, t(2) , ‘Color’, ‘k’); % Adjust LineWidth as needed, matrix within fimplicit is made
%fimplicit(f1_2, [5 370 -200 0], ‘LineWidth’, t(2) , ‘Color’, ‘k’); % Adjust LineWidth as needed
%fimplicit(f2_1, [9 175 -200 0], ‘LineWidth’, t(3) , ‘Color’, ‘k’); % Adjust LineWidth as needed, matrix within fimplicit is made
fimplicit(f2_2, [9 175 -200 0], ‘LineWidth’, t(3) , ‘Color’, ‘k’); % Adjust LineWidth as needed
%fimplicit(f3_1, [55 285 -200 0], ‘LineWidth’, t(1) , ‘Color’, ‘k’); % Adjust LineWidth as needed, matrix within fimplicit is made
fimplicit(f3_2, [55 285 -200 0], ‘LineWidth’, t(1) , ‘Color’, ‘k’); % Adjust LineWidth as needed
%fimplicit(f4_1, [55 347 -200 0], ‘LineWidth’, t(1) , ‘Color’, ‘k’); % Adjust LineWidth as needed, matrix within fimplicit is made
fimplicit(f4_2, [55 347 -200 0], ‘LineWidth’, t(1) , ‘Color’, ‘k’); % Adjust LineWidth as needed
fimplicit(f5_1, [40 298 -200 0], ‘LineWidth’, t(2) , ‘Color’, ‘k’); % Adjust LineWidth as needed, matrix within fimplicit is made
%fimplicit(f5_2, [40 298 -200 0], ‘LineWidth’, t(2) , ‘Color’, ‘k’); % Adjust LineWidth as needed
fimplicit(f6_1, [40 252 -200 0], ‘LineWidth’, t(2) , ‘Color’, ‘k’); % Adjust LineWidth as needed, matrix within fimplicit is made
%fimplicit(f6_2, [40 252 -200 0], ‘LineWidth’, t(2) , ‘Color’, ‘k’); % Adjust LineWidth as needed
fimplicit(f7_1, [40 100 -160 0], ‘LineWidth’, t(1) , ‘Color’, ‘k’); % Adjust LineWidth as needed, matrix within fimplicit is made
%fimplicit(f7_2, [40 100 -160 0], ‘LineWidth’, t(1) , ‘Color’, ‘k’); % Adjust LineWidth as needed
plot([crossvein1.x1 crossvein1.x2], [crossvein1.y1 crossvein1.y2], ‘LineWidth’,t(2), ‘Color’, ‘r’)
plot([crossvein4.x1 crossvein4.x2], [crossvein4.y1 crossvein4.y2], ‘LineWidth’,t(2), ‘Color’, ‘r’)
plot([crossvein5.x1 crossvein5.x2], [crossvein5.y1 crossvein5.y2], ‘LineWidth’,t(2), ‘Color’, ‘r’)
plot([crossvein6.x1 crossvein6.x2], [crossvein6.y1 crossvein6.y2], ‘LineWidth’,t(2), ‘Color’, ‘r’)
% Plot settings
axis([0 400 -200 0]);
xlabel(‘X’);
ylabel(‘Y’);
title(‘Asydentus Venation’);
hold off; I want to be able to convert a set of image representations of wing venation patterns to a multiple array format.
For each wing vein, the array needs to include
L, h = xy coordinate for the start of the vein
vt = the thickness of the vein
Lf, hf = xy coordinate for the end of the vein
R = rough aggregate radius of the arc of the vein.
For each cross-vein, the array needs to include
L1% = the starting x position of the connecting cross-vein
L2% = the finishing x position of the connecting cross-vein
ct = thickness of the cross vein
The total array is about 69 values long with it being split into a 7×6 and 3×9 array for vein and cross-vein properties respectively.
I’ve had some success with the reverse of this (taking an encoded array and converting that into an image representation, attached below with an example of one of the images that will be used).
%% Define the vein and cross_vein arrays
asydentus.vein = [1.25 25 2 92.5 29.5 39.47041396 ; 2.25 27.5 3 43.75 16.5 -14.73949649 ; 13.75 29.5 1 71.25 21 -33.2551027 ; 13.75 29.5 1 86.75 26.5 -79.65111699 ; 10 37.5 2 74.5 58.5 43.17494694 ; 10 37.5 2 63 93 17.18991587 ; 10 37.5 1 25 72.5 4.144372635];
asydentus.cross_vein = [13.25 15 2 ; 0 0 0 ; 0 0 0 ; 25.25 26.75 2 ; 30.75 30.5 2 ; 20.5 19.25 2 ; 0 0 0 ; 0 0 0 ; 0 0 0];
% Scaling factors
sf1 = 4;
sf2 = -2;
sf3 = 20;
%% Define startpoints and endpoints for veins and cross-veins and define radius for veins
vein1.p1 = [sf1 * asydentus.vein(1,1), sf2 * asydentus.vein(1,2)]; % vein 1 startpoint
vein1.p2 = [sf1 * asydentus.vein(1,4), sf2 * asydentus.vein(1,5)]; % vein 1 endpoint
vein1.r = sf3 * [asydentus.vein(1,6)]; % vein 1 radius value
vein2.p1 = [sf1 * asydentus.vein(2,1), sf2 * asydentus.vein(2,2)]; % vein 2 startpoint
vein2.p2 = [sf1 * asydentus.vein(2,4), sf2 * asydentus.vein(2,5)]; % vein 2 endpoint
vein2.r = sf3 * [asydentus.vein(2,6)]; % vein 2 radius value
vein3.p1 = [sf1 * asydentus.vein(3,1), sf2 * asydentus.vein(3,2)]; % vein 3 startpoint
vein3.p2 = [sf1 * asydentus.vein(3,4), sf2 * asydentus.vein(3,5)]; % vein 3 endpoint
vein3.r = sf3 * [asydentus.vein(3,6)]; % vein 3 radius value
vein4.p1 = [sf1 * asydentus.vein(4,1), sf2 * asydentus.vein(4,2)]; % vein 4 startpoint
vein4.p2 = [sf1 * asydentus.vein(4,4), sf2 * asydentus.vein(4,5)]; % vein 4 endpoint
vein4.r = sf3 * [asydentus.vein(4,6)]; % vein 4 radius value
vein5.p1 = [sf1 * asydentus.vein(5,1), sf2 * asydentus.vein(5,2)]; % vein 5 startpoint
vein5.p2 = [sf1 * asydentus.vein(5,4), sf2 * asydentus.vein(5,5)]; % vein 5 endpoint
vein5.r = sf3 * [asydentus.vein(5,6)]; % vein 5 radius value
vein6.p1 = [sf1 * asydentus.vein(6,1), sf2 * asydentus.vein(6,2)]; % vein 6 startpoint
vein6.p2 = [sf1 * asydentus.vein(6,4), sf2 * asydentus.vein(6,5)]; % vein 6 endpoint
vein6.r = sf3 * [asydentus.vein(6,6)]; % vein 6 radius value
vein7.p1 = [sf1 * asydentus.vein(7,1), sf2 * asydentus.vein(7,2)]; % vein 7 startpoint
vein7.p2 = [sf1 * asydentus.vein(7,4), sf2 * asydentus.vein(7,5)]; % vein 7 endpoint
vein7.r = sf3 * [asydentus.vein(7,6)]; % vein 7 radius value
crossvein1.x1 = sf1 * [asydentus.cross_vein(1,1)]; % crossvein 1 start x-coordinate
crossvein1.x2 = sf1 * [asydentus.cross_vein(1,2)]; % crossvein 1 end x-coordinate
crossvein4.x1 = sf1 * [asydentus.cross_vein(4,1)]; % crossvein 4 start x-coordinate
crossvein4.x2 = sf1 * [asydentus.cross_vein(4,2)]; % crossvein 4 end x-coordinate
crossvein5.x1 = sf1 * [asydentus.cross_vein(5,1)]; % crossvein 5 start x-coordinate
crossvein5.x2 = sf1 * [asydentus.cross_vein(5,2)]; % crossvein 5 end x-coordinate
crossvein6.x1 = sf1 * [asydentus.cross_vein(6,1)]; % crossvein 6 start x-coordinate
crossvein6.x2 = sf1 * [asydentus.cross_vein(6,1)]; % crossvein 6 end x-coordinate
%% Solve for centre of radius and cross-vein coordinates
syms x1 y1
[x1, y1] = solve((x1-vein1.p1(1))^2+(y1-vein1.p1(2))^2==vein1.r^2, (x1-vein1.p2(1))^2+(y1-vein1.p2(2))^2==vein1.r^2, x1, y1);
% vein 1 centre of radius
arc1_c1 = double([x1(1), y1(1)]);
arc1_c2 = double([x1(2), y1(2)]);
syms x2 y2
[x2, y2] = solve((x2-vein2.p1(1))^2+(y2-vein2.p1(2))^2==vein2.r^2, (x2-vein2.p2(1))^2+(y2-vein2.p2(2))^2==vein2.r^2, x2, y2);
% vein 2 centre of radius
arc2_c1 = double([x2(1), y2(1)]);
arc2_c2 = double([x2(2), y2(2)]);
syms x3 y3
[x3, y3] = solve((x3-vein3.p1(1))^2+(y3-vein3.p1(2))^2==vein3.r^2, (x3-vein3.p2(1))^2+(y3-vein3.p2(2))^2==vein3.r^2, x3, y3);
% vein 3 centre of radius
arc3_c1 = double([x3(1), y3(1)]);
arc3_c2 = double([x3(2), y3(2)]);
syms x4 y4
[x4, y4] = solve((x4-vein4.p1(1))^2+(y4-vein4.p1(2))^2==vein4.r^2, (x4-vein4.p2(1))^2+(y4-vein4.p2(2))^2==vein4.r^2, x4, y4);
% vein 4 centre of radius
arc4_c1 = double([x4(1), y4(1)]);
arc4_c2 = double([x4(2), y4(2)]);
syms x5 y5
[x5, y5] = solve((x5-vein5.p1(1))^2+(y5-vein5.p1(2))^2==vein5.r^2, (x5-vein5.p2(1))^2+(y5-vein5.p2(2))^2==vein5.r^2, x5, y5);
% vein 5 centre of radius
arc5_c1 = double([x5(1), y5(1)]);
arc5_c2 = double([x5(2), y5(2)]);
syms x6 y6
[x6, y6] = solve((x6-vein6.p1(1))^2+(y6-vein6.p1(2))^2==vein6.r^2, (x6-vein6.p2(1))^2+(y6-vein6.p2(2))^2==vein6.r^2, x6, y6);
% vein 6 centre of radius
arc6_c1 = double([x6(1), y6(1)]);
arc6_c2 = double([x6(2), y6(2)]);
syms x7 y7
[x7, y7] = solve((x7-vein7.p1(1))^2+(y7-vein7.p1(2))^2==vein7.r^2, (x7-vein7.p2(1))^2+(y7-vein7.p2(2))^2==vein7.r^2, x7, y7);
% vein 7 centre of radius
arc7_c1 = double([x7(1), y7(1)]);
arc7_c2 = double([x7(2), y7(2)]);
syms yc1_1
[yc1_1] = solve ((crossvein1.x1(1) – arc1_c1(1)).^2 + (yc1_1 – arc1_c1(2)).^2 – vein1.r^2, (-200<=yc1_1)<=0);
crossvein1.y1 = yc1_1;
syms yc1_2
[yc1_2] = solve ((crossvein1.x2(1) – arc2_c2(1)).^2 + (yc1_2 – arc2_c2(2)).^2 – vein2.r^2, (-200<=yc1_2)<=0);
crossvein1.y2 = yc1_2;
syms yc4_1
[yc4_1] = solve ((crossvein4.x1(1) – arc4_c2(1)).^2 + (yc4_1 – arc4_c2(2)).^2 – vein4.r^2, (-200<=yc4_1)<=0);
crossvein4.y1 = yc4_1;
syms yc4_2
[yc4_2] = solve ((crossvein4.x2(1) – arc5_c1(1)).^2 + (yc4_2 – arc5_c1(2)).^2 – vein5.r^2, (-200<=yc4_2)<=0);
crossvein4.y2 = yc4_2;
syms yc5_1
[yc5_1] = solve ((crossvein5.x1(1) – arc5_c1(1)).^2 + (yc5_1 – arc5_c1(2)).^2 – vein5.r^2, (-200<=yc5_1)<=0);
crossvein5.y1 = yc5_1;
syms yc5_2
[yc5_2] = solve ((crossvein5.x2(1) – arc6_c1(1)).^2 + (yc5_2 – arc6_c1(2)).^2 – vein6.r^2, (-200<=yc5_2)<=0);
crossvein5.y2 = yc5_2;
syms yc6_1
[yc6_1] = solve ((crossvein6.x1(1) – arc6_c1(1)).^2 + (yc6_1 – arc6_c1(2)).^2 – vein6.r^2, (-200<=yc6_1)<=0);
crossvein6.y1 = yc6_1;
syms yc6_2
[yc6_2] = solve ((crossvein6.x2(1) – arc7_c1(1)).^2 + (yc6_2 – arc7_c1(2)).^2 – vein7.r^2, (-200<=yc6_2)<=0);
crossvein6.y2 = yc6_2;
%% Define Arc Function for vein radius
figure;
hold on;
% Define the implicit functions for the circles
f1_1 = @(X1, Y1) (X1 – arc1_c1(1)).^2 + (Y1 – arc1_c1(2)).^2 – vein1.r^2;
f1_2 = @(X1, Y1) (X1 – arc1_c2(1)).^2 + (Y1 – arc1_c2(2)).^2 – vein1.r^2;
f2_1 = @(X2, Y2) (X2 – arc2_c1(1)).^2 + (Y2 – arc2_c1(2)).^2 – vein2.r^2;
f2_2 = @(X2, Y2) (X2 – arc2_c2(1)).^2 + (Y2 – arc2_c2(2)).^2 – vein2.r^2;
f3_1 = @(X3, Y3) (X3 – arc3_c1(1)).^2 + (Y3 – arc3_c1(2)).^2 – vein3.r^2;
f3_2 = @(X3, Y3) (X3 – arc3_c2(1)).^2 + (Y3 – arc3_c2(2)).^2 – vein3.r^2;
f4_1 = @(X4, Y4) (X4 – arc4_c1(1)).^2 + (Y4 – arc4_c1(2)).^2 – vein4.r^2;
f4_2 = @(X4, Y4) (X4 – arc4_c2(1)).^2 + (Y4 – arc4_c2(2)).^2 – vein4.r^2;
f5_1 = @(X5, Y5) (X5 – arc5_c1(1)).^2 + (Y5 – arc5_c1(2)).^2 – vein5.r^2;
f5_2 = @(X5, Y5) (X5 – arc5_c2(1)).^2 + (Y5 – arc5_c2(2)).^2 – vein5.r^2;
f6_1 = @(X6, Y6) (X6 – arc6_c1(1)).^2 + (Y6 – arc6_c1(2)).^2 – vein6.r^2;
f6_2 = @(X6, Y6) (X6 – arc6_c2(1)).^2 + (Y6 – arc6_c2(2)).^2 – vein6.r^2;
f7_1 = @(X7, Y7) (X7 – arc7_c1(1)).^2 + (Y7 – arc7_c1(2)).^2 – vein7.r^2;
f7_2 = @(X7, Y7) (X7 – arc7_c2(1)).^2 + (Y7 – arc7_c2(2)).^2 – vein7.r^2;
%% Plot the veins and cross-veins using fimplicit
% Depending on whether the arc of the vein is 0<=180 or 180<=360 will
% decide which implicit function is used
% use image representations as a guide
t = [1; 2; 3]; % Line Thickness
fimplicit(f1_1, [5 370 -200 0], ‘LineWidth’, t(2) , ‘Color’, ‘k’); % Adjust LineWidth as needed, matrix within fimplicit is made
%fimplicit(f1_2, [5 370 -200 0], ‘LineWidth’, t(2) , ‘Color’, ‘k’); % Adjust LineWidth as needed
%fimplicit(f2_1, [9 175 -200 0], ‘LineWidth’, t(3) , ‘Color’, ‘k’); % Adjust LineWidth as needed, matrix within fimplicit is made
fimplicit(f2_2, [9 175 -200 0], ‘LineWidth’, t(3) , ‘Color’, ‘k’); % Adjust LineWidth as needed
%fimplicit(f3_1, [55 285 -200 0], ‘LineWidth’, t(1) , ‘Color’, ‘k’); % Adjust LineWidth as needed, matrix within fimplicit is made
fimplicit(f3_2, [55 285 -200 0], ‘LineWidth’, t(1) , ‘Color’, ‘k’); % Adjust LineWidth as needed
%fimplicit(f4_1, [55 347 -200 0], ‘LineWidth’, t(1) , ‘Color’, ‘k’); % Adjust LineWidth as needed, matrix within fimplicit is made
fimplicit(f4_2, [55 347 -200 0], ‘LineWidth’, t(1) , ‘Color’, ‘k’); % Adjust LineWidth as needed
fimplicit(f5_1, [40 298 -200 0], ‘LineWidth’, t(2) , ‘Color’, ‘k’); % Adjust LineWidth as needed, matrix within fimplicit is made
%fimplicit(f5_2, [40 298 -200 0], ‘LineWidth’, t(2) , ‘Color’, ‘k’); % Adjust LineWidth as needed
fimplicit(f6_1, [40 252 -200 0], ‘LineWidth’, t(2) , ‘Color’, ‘k’); % Adjust LineWidth as needed, matrix within fimplicit is made
%fimplicit(f6_2, [40 252 -200 0], ‘LineWidth’, t(2) , ‘Color’, ‘k’); % Adjust LineWidth as needed
fimplicit(f7_1, [40 100 -160 0], ‘LineWidth’, t(1) , ‘Color’, ‘k’); % Adjust LineWidth as needed, matrix within fimplicit is made
%fimplicit(f7_2, [40 100 -160 0], ‘LineWidth’, t(1) , ‘Color’, ‘k’); % Adjust LineWidth as needed
plot([crossvein1.x1 crossvein1.x2], [crossvein1.y1 crossvein1.y2], ‘LineWidth’,t(2), ‘Color’, ‘r’)
plot([crossvein4.x1 crossvein4.x2], [crossvein4.y1 crossvein4.y2], ‘LineWidth’,t(2), ‘Color’, ‘r’)
plot([crossvein5.x1 crossvein5.x2], [crossvein5.y1 crossvein5.y2], ‘LineWidth’,t(2), ‘Color’, ‘r’)
plot([crossvein6.x1 crossvein6.x2], [crossvein6.y1 crossvein6.y2], ‘LineWidth’,t(2), ‘Color’, ‘r’)
% Plot settings
axis([0 400 -200 0]);
xlabel(‘X’);
ylabel(‘Y’);
title(‘Asydentus Venation’);
hold off; image analysis, digital image processing MATLAB Answers — New Questions