Solarplot

function []= SolarPlotJS()
fp=fopen('1.txt','r')
%rootpath = strtrim(fscanf(fp,'%s\n'))

while ~feof(fp)
    s = strtrim(fgets(fp))
    if max(size(s))>10
        
        SolarPlot(s)
    end
end

fclose(fp)

function dest = getDest(s)

    splitPos = findstr(s, '\');
    n = max(size(splitPos));
    p=splitPos(n-1);
    p2=max(size(s));
    aa = strrep(s(p+1:p2), '\','_');
    dest = sprintf( '%s\%s', s(1:p),aa  );
    
function []= SolarPlot(Path)
%for i= 1:length(PathArray)
    close all;
    
    dest = getDest(Path);
    %Path = PathArray{i};
    % thickness range, keep display range 200um
    offtp = 0;
    offbm = 0;
    offTh = 0;
    minTh = 110 + offTh;
    maxTh = 280 + offTh;
    mintp =  100 + offtp;
    maxtp =  350 + offtp;
    minbm = -100 + offbm;
    maxbm =  150 + offbm;
    %
    % minTh = 160 + offTh
    % maxTh = 500 + offTh
    % mintp =  100 + offtp
    % maxtp =  450 + offtp%
    % minbm = -100 + offbm
    % maxbm =  100 + offbm
    % minTh =  0
    % maxTh =  600
    % mintp =   0
    % maxtp =  400
    % minbm = -200
    % maxbm =  200

    
    filePath= sprintf('%s\\pair0\\Btm\\deripple.tif', Path);
    img0b= imread(filePath);
    coOff(1)= 5;
    coOff(2)= 65;
    szOp(1)= size(img0b, 2)-10;
    szOp(2)= size(img0b, 1)-70;

    img0b= img0b(coOff(2):(coOff(2)+ szOp(2)), coOff(1):(coOff(1)+ szOp(1)));
    filePath= sprintf('%s\\pair0\\top\\deripple.tif', Path);
    img0t= imread(filePath);
    img0t= img0t(coOff(2):(coOff(2)+ szOp(2)), coOff(1):(coOff(1)+ szOp(1)));
    filePath= sprintf('%s\\pair1\\Btm\\deripple.tif', Path);
    img1b= imread(filePath);
    coOff2(1)= 5;
    coOff2(2)= 25;
    szOp2(1)= size(img1b, 2)-10;
    szOp2(2)= size(img1b, 1)-90;
    
    img1b= img1b(coOff2(2):(coOff2(2)+ szOp2(2)), coOff2(1):(coOff2(1)+ szOp2(1)));
    filePath= sprintf('%s\\pair1\\top\\deripple.tif', Path);
    img1t= imread(filePath);
    img1t= img1t(coOff2(2):(coOff2(2)+ szOp2(2)), coOff2(1):(coOff2(1)+ szOp2(1)));

    % 3D surface
    scrsz = get(0,'ScreenSize');
    % f1= figure('Position',[1 scrsz(4)/2-300 scrsz(3) scrsz(4)/2]);
    f1= figure('Position',[1 scrsz(4)/2-300 scrsz(3) scrsz(4)/2]);
    set(f1,'name','Profile','Numbertitle','off')
    resX = 27;
    resY = 117*2;
    samX = 50;
    samY = 5;


    % for thickness, select line cross profile for substraction
    % idy = [50 100 150]
    % tiT{1} = sprintf('L-%d',idy(1));
    % tiT{2} = sprintf('L-%d',idy(2));
    % tiT{3} = sprintf('L-%d',idy(3));

    idy = int32(size(img0b,1)/2); %100
    idx = int32(size(img0b,2)/2);
    tiy = sprintf('Middle Row');
    tix = sprintf('Middle Column');

    % tiy = sprintf('Row-%d',idy);
    % tix = sprintf('Column-%d',idy);


    % ti0{1} = sprintf('T0-%d',idy(1));
    % ti0{2} = sprintf('T0-%d',idy(2));
    % ti0{3} = sprintf('T0-%d',idy(3));
    %
    % ti1{1} = sprintf('T1-%d',idy(1));
    % ti1{2} = sprintf('T1-%d',idy(2));
    % ti1{3} = sprintf('T1-%d',idy(3));


    subplot(2, 2, 1);
    % imagesc(-img0t, [-300, 300]), title('Pair 0, Top'), colorbar();
    T = double(-img0t(1:samY:end,1:samX:end));
    surface('XData',[1:size(T,2)]*resX*samX/1000,...
        'YData',[1:size(T,1)]*resY*samY/1000,...
        'ZData',T,...
        'CData',T);
    colorbar('NorthOutside');
    axis tight;
    xlabel('X (unit:mm)'); xlabel('Y (unit:mm)')
    zlabel('Z (unit:um)')
    view(10,60)
    set(gca, 'fontsize',6)
    t = title('Pair0, Top');
    set(t,'fontsize',10)
    axis([0 size(T,2)*resX*samX/1000 0 size(T,1)*resY*samY/1000  mintp maxtp])
    %
    subplot(2, 2, 2);
    % imagesc(-img1t, [-300, 300]), title('Pair 1, Top'), colorbar();
    T = double(-img1t(1:samY:end,1:samX:end));
    surface('XData',[1:size(T,2)]*resX*samX/1000,...
        'YData',[1:size(T,1)]*resY*samY/1000,...
        'ZData',T,...
        'CData',T);
    colorbar('NorthOutside');
    axis tight;
    xlabel('X (unit:mm)'); ylabel('Y (unit:mm)')
    zlabel('Z (unit:um)')
    view(10,60)
    set(gca, 'fontsize',6)
    t = title('Pair1, Top');
    set(t,'fontsize',10)
    axis([0 size(T,2)*resX*samX/1000 0 size(T,1)*resY*samY/1000  mintp maxtp])

    %
    subplot(2, 2, 3);
    % imagesc(-img0b, [-300, 300]), title('Pair 0, Bottom'), colorbar();
    T = double(-img0b(1:samY:end,1:samX:end));
    surface('XData',[1:size(T,2)]*resX*samX/1000,...
        'YData',[1:size(T,1)]*resY*samY/1000,...
        'ZData',T,...
        'CData',T)
    colorbar('NorthOutside');
    axis tight;
    xlabel('X (unit:mm)'); ylabel('Y (unit:mm)')
    zlabel('Z (unit:um)')
    view(10,60)
    set(gca, 'fontsize',6)
    t = title('Pair0, Bottom')
    set(t,'fontsize',10)
    axis([0 size(T,2)*resX*samX/1000 0 size(T,1)*resY*samY/1000  minbm maxbm])

    %
    subplot(2, 2, 4);
    % imagesc(-img1b, [-300, 300]), title('Pair 1, Bottom'), colorbar();
    T = double(-img1b(1:samY:end,1:samX:end));
    surface('XData',[1:size(T,2)]*resX*samX/1000,...
        'YData',[1:size(T,1)]*resY*samY/1000,...
        'ZData',T,...
        'CData',T)
    colorbar('NorthOutside');
    axis tight;
    xlabel('X (unit:mm)'); ylabel('Y (unit:mm)')
    zlabel('Z (unit:um)')
    view(10,60)
    set(gca, 'fontsize',6)
    t = title('Pair1, Bottom');
    set(t,'fontsize',10)
    axis([0 size(T,2)*resX*samX/1000 0 size(T,1)*resY*samY/1000  minbm maxbm])


    %%
    Grab = getframe(gcf,[1 1 scrsz(3) scrsz(4)/2]);
    imwrite(Grab.cdata, sprintf('%sProfile.bmp', dest));


    %%


    %
    f2= figure('Position',[1 scrsz(4)/2-300 scrsz(3) scrsz(4)/2]);
    set(f2,'name','Profile','Numbertitle','off')
    subplot(2, 2, 1);
    % surface('XData',[1:size(T,2)]*resX*samX/1000,...
    %        'YData',[1:size(T,1)]*resY*samY/1000,...
    %        'ZData',double(img0b(1:samY:end,1:samX:end)-img0t(1:samY:end,1:samX:end)),...
    %        'CData',double(img0b(1:samY:end,1:samX:end)-img0t(1:samY:end,1:samX:end)))
    T = double(img0b(1:samY:end,1:samX:end)-img0t(1:samY:end,1:samX:end));

    T = T;%-281.8724


    surface('XData',(1:size(T,2))*resX*samX/1000,...
        'YData',(1:size(T,1))*resY*samY/1000,...
        'ZData', T,...
        'CData', T)
    colorbar('NorthOutside');
    axis tight;
    xlabel('X (unit:mm)'); ylabel('Y (unit:mm)')
    zlabel('Z (unit:um)')
    view(10,60)
    set(gca, 'fontsize',6)
    t = title('Pair0, Thickness');
    set(t,'fontsize',10)
    axis([0 size(T,2)*resX*samX/1000 0 size(T,1)*resY*samY/1000  minTh maxTh])


    subplot(2, 2, 2);
    T = double(img1b(1:samY:end,1:samX:end)-img1t(1:samY:end,1:samX:end));
    surface('XData', (1:size(T,2))*resX*samX/1000,...
        'YData', (1:size(T,1))*resY*samY/1000,...
        'ZData',T,...
        'CData',T);
    colorbar('NorthOutside');
    axis tight;
    xlabel('X (unit:mm)'); ylabel('Y (unit:mm)')
    zlabel('Z (unit:um)')
    view(10,60)
    set(gca, 'fontsize',6)
    t = title('Pair1, Thickness'),
    set(t,'fontsize',10)
    axis([0 size(T,2)*resX*samX/1000 0 size(T,1)*resY*samY/1000 minTh maxTh])


    img0bs = img0b;
    img0ts = img0t;
    img1bs = img1b;
    img1ts = img1t;

    L0by = img0bs(idy,:);
    L0ty = img0ts(idy,:);
    L1by = img1bs(idy,:);
    L1ty = img1ts(idy,:);
    T0y = L0by - L0ty;
    T1y = L1by - L1ty;
    miny= min(size(T0y,2),size(T1y,2));
    Ty  = [T0y(1:miny); T1y(1:miny)]';


    Ty(:,1) = Ty(:,1);% -281.8724

    subplot(2,2,3);
    hold on; plot(([1:size(Ty,1)]*resX/1000)',Ty(:,1),'r'); %legend(tix);
    hold on; plot(([1:size(Ty,1)]*resX/1000)',Ty(:,2),'b'); %legend(tix);
    legend('Pair0','Pair1');
    title('Thinckness profile along middle row');
    axis([0  size(Ty,1)*resX/1000 minTh maxTh])


    L0bx = img0b(:,idx);
    L0tx = img0t(:,idx);
    L1bx = img1b(:,idx);
    L1tx = img1t(:,idx);
    T0x = L0bx - L0tx;
    T1x = L1bx - L1tx;
    minx= min(size(T0x,1),size(T1x,1));
    Tx  = [T0x(1:minx) T1x(1:minx)];

    Tx(:,1) = Tx(:,1);% -281.8724

    subplot(2,2,4);
    hold on; plot(([1:size(Tx,1)]*resY/1000)',Tx(:,1),'r'); %legend(tix);
    hold on; plot(([1:size(Tx,1)]*resY/1000)',Tx(:,2),'b'); %
    legend('Pair0','Pair1');
    title('Thinckness profile along middle column');
    axis([0  size(Tx,1)*resY/1000 minTh maxTh])

    Grab = getframe(gcf,[1 1 scrsz(3) scrsz(4)/2]);
    imwrite(Grab.cdata, sprintf('%sThinckness.bmp', dest));
%end

Powered by Jekyll and Theme by solid

本站总访问量