diff --git a/Data-Analyzer/plotImages.m b/Data-Analyzer/plotImages.m index f835ff9..fb0d63d 100644 --- a/Data-Analyzer/plotImages.m +++ b/Data-Analyzer/plotImages.m @@ -2,22 +2,23 @@ groupList = ["/images/MOT_3D_Camera/in_situ_absorption", "/images/ODT_1_Axis_Camera/in_situ_absorption", "/images/ODT_2_Axis_Camera/in_situ_absorption", "/images/Horizontal_Axis_Camera/in_situ_absorption", "/images/Vertical_Axis_Camera/in_situ_absorption"]; -folderPath = "C:/Users/Karthik/Documents/GitRepositories/Calculations/24/"; +folderPath = "C:/Users/Karthik/Documents/GitRepositories/Calculations/Data-Analyzer/20/"; -run = '0086'; +run = '0140'; folderPath = strcat(folderPath, run); -cam = 5; +cam = 4; -angle = 90; -center = [2100, 1150]; -span = [500, 500]; -fraction = [0.1, 0.1]; +angle = 0; +center = [95, 1042]; +span = [50, 50]; +fraction = [0.1, 0.1]; -pixel_size = 4.6e-6; +pixel_size = 5.86e-6; +remove_fringes = false; -%% Compute OD image, rotate and extract ROI for analysis +% Compute OD image, rotate and extract ROI for analysis % Get a list of all files in the folder with the desired file name pattern. filePattern = fullfile(folderPath, '*.h5'); files = dir(filePattern); @@ -35,36 +36,48 @@ for k = 1 : length(files) bkg_img = im2double(imrotate(h5read(fullFileName, append(groupList(cam), "/background")), angle)); dark_img = im2double(imrotate(h5read(fullFileName, append(groupList(cam), "/dark")), angle)); - refimages(:,:,k) = subtract_offset(crop_image(bkg_img, center, span), fraction); - absimages(:,:,k) = subtract_offset(crop_image(calculate_OD(atm_img, bkg_img, dark_img), center, span), fraction); + refimages(:,:,k) = subtract_offset(crop_image(bkg_img, center, span), fraction)'; + absimages(:,:,k) = subtract_offset(crop_image(calculate_OD(atm_img, bkg_img, dark_img), center, span), fraction)'; end -%% Fringe removal -optrefimages = removefringesInImage(absimages, refimages); -absimages_fringe_removed = absimages(:, :, :) - optrefimages(:, :, :); - -nimgs = size(absimages_fringe_removed,3); -od_imgs = cell(1, nimgs); -for i = 1:nimgs - od_imgs{i} = absimages_fringe_removed(:, :, i); +% Fringe removal +if remove_fringes + optrefimages = removefringesInImage(absimages, refimages); + absimages_fringe_removed = absimages(:, :, :) - optrefimages(:, :, :); + + nimgs = size(absimages_fringe_removed,3); + od_imgs = cell(1, nimgs); + for i = 1:nimgs + od_imgs{i} = absimages_fringe_removed(:, :, i); + end +else + nimgs = size(absimages,3); + od_imgs = cell(1, nimgs); + for i = 1:nimgs + od_imgs{i} = absimages(:, :, i); + end end %% + figure(1) clf -r = 120; -x = 250; -y = 250; +set(gcf,'Position',[50 50 950 750]) + +% Calculate the x and y limits for the cropped image +y_min = center(1) - span(2) / 2; +y_max = center(1) + span(2) / 2; +x_min = center(2) - span(1) / 2; +x_max = center(2) + span(1) / 2; + +% Generate x and y arrays representing the original coordinates for each pixel +x_range = linspace(x_min, x_max, span(1)); +y_range = linspace(y_min, y_max, span(2)); + +% Display the cropped image for k = 1 : length(od_imgs) - imagesc(xvals, yvals, od_imgs{k}) - hold on - th = 0:pi/50:2*pi; - xunit = r * cos(th) + x; - yunit = r * sin(th) + y; - h = plot(xunit, yunit, Color='yellow'); - xlabel('µm', 'FontSize', 16) - ylabel('µm', 'FontSize', 16) + imagesc(x_range, y_range, od_imgs{k}) axis equal tight; hcb = colorbar; hL = ylabel(hcb, 'Optical Density', 'FontSize', 16); @@ -72,11 +85,42 @@ for k = 1 : length(od_imgs) colormap jet; set(gca,'CLim',[0 1.0]); set(gca,'YDir','normal') - title('DMD projection: Circle of radius 200 pixels', 'FontSize', 16); + set(gca, 'YTick', linspace(y_min, y_max, 5)); % Define y ticks + set(gca, 'YTickLabel', flip(linspace(y_min, y_max, 5))); % Flip only the labels + xlabel('X', 'Interpreter', 'tex','FontSize',16); + ylabel('Y', 'Interpreter', 'tex','FontSize',16); - drawnow; + drawnow + pause(0.5) end +%% Overlay images + +% image_below = ; +% image_top = ; + +% Display the first image (opaque) +figure (2); +clf +set(gcf,'Position',[50 50 950 750]) + +imagesc(x_range, y_range, image_below); +hold on; % Allow overlaying of the second image +h = imagesc(x_range, y_range, image_top); % Display the second image (translucent) +set(h, 'AlphaData', 0.6); % Adjust transparency: 0 is fully transparent, 1 is fully opaque +axis equal tight; +hcb = colorbar; +hL = ylabel(hcb, 'Optical Density', 'FontSize', 16); +set(hL,'Rotation',-90); +colormap jet; +set(gca,'CLim',[0 1.0]); +set(gca,'YDir','normal') +set(gca, 'YTick', linspace(y_min, y_max, 5)); % Define y ticks +set(gca, 'YTickLabel', flip(linspace(y_min, y_max, 5))); % Flip only the labels +xlabel('X', 'Interpreter', 'tex','FontSize',16); +ylabel('Y', 'Interpreter', 'tex','FontSize',16); +hold off; + %% Helper Functions function ret = get_offset_from_corner(img, x_fraction, y_fraction)