How can I rotate my images
2 views (last 30 days)
Show older comments
So I have these imgaes being generated from my drive. But they are not jpg images. So I am having a hard time getting them to rotate. Can anyone give me advice on what to do? Thanks!
clear;clc;close all;
myfolds = {'P:\IRB_STUDY00146119_Xe_Imaging\20230320_Xe-059',...
'P:\IRB_STUDY00146119_Xe_Imaging\20221018_Xe-045',...
'P:\IRB_STUDY00146119_Xe_Imaging\20221025_Xe-046',...
'P:\IRB_STUDY00146119_Xe_Imaging\20221028_Xe-047',...
'P:\IRB_STUDY00146119_Xe_Imaging\20221115_Xe-049',...
'P:\IRB_STUDY00146119_Xe_Imaging\20230109_Xe-054',...
'P:\IRB_STUDY00146119_Xe_Imaging\20230111_Xe-052',...
'P:\IRB_STUDY00146119_Xe_Imaging\20230112_Xe-051',...
'P:\IRB_STUDY00146119_Xe_Imaging\20230118_Xe-048',...
'P:\IRB_STUDY00146119_Xe_Imaging\20230309_Xe-058',...
'P:\IRB_STUDY00146616_COVID_Xe_MRI\20221109_CXe-041',...
'P:\IRB_STUDY00146616_COVID_Xe_MRI\20221201_CXe-038_02',...
'P:\IRB_STUDY00146616_COVID_Xe_MRI\20221031_CXe-020_02',...
};
for ii = 1:length(myfolds)
try
load(fullfile(myfolds{ii},'Dynamic_CSI_Workspace.mat'));
load(fullfile(myfolds{ii},'All_in_One_Analysis','Oscillation_Amps_Multiple_Ways.mat'));
figure('Name','Select Left then Right lung');
imagesc(Gas(:,:,1));
l = roipoly();
r = roipoly();
Mask = l+r;
close;
RBC_Osc_Proj(end-7:end,:) = [];
RBC_Osc_Proj(:,end-7:end) = [];
RBC_Osc_Proj(1:8,:) = [];
RBC_Osc_Proj(:,1:8) = [];
RBC2Mem_Osc_Proj(end-7:end,:) = [];
RBC2Mem_Osc_Proj(:,end-7:end) = [];
RBC2Mem_Osc_Proj(1:8,:) = [];
RBC2Mem_Osc_Proj(:,1:8) = [];
tROP = RBC_Osc_Proj;
tROP(isnan(tROP)) = 0;
tRMOP = RBC2Mem_Osc_Proj;
tRMOP(isnan(tRMOP)) = 0;
tmpRBC_Osc_Proj = imresize(tROP,[8,8]);
tmpRBC2Mem_Osc_Proj = imresize(tRMOP,[8,8]);
figure('Name',['Image for ii = ' num2str(ii)]);
subplot(2,3,1)
imagesc(RBCAmp.*Mask);axis square; axis off;clim([0 8]);
matrixa= [imdivide(RBCAmp.*Mask,1)];
matrixa(isnan(matrixa))=0;
A1=matrixa(1:4,1:4);
A2=mean(A1,"all",'omitnan');
B1=matrixa(5:8,1:4);
B2=mean(B1,"all");
C1=matrixa(1:4,5:8);
C2=mean(C1,"all");
D1=matrixa(5:8,5:8);
D2=mean(D1,"all");
RBC1 = [A2,B2;C2,D2];
disp('RBCAmp.*Mask Avg in Quads')
disp(RBC1);
subplot(2,3,2)
imagesc(RBC_Osc_Proj);axis square;axis off;clim([0 20]);
subplot(2,3,3)
imagesc(tmpRBC_Osc_Proj);axis square;axis off;clim([0 20]);
matrixa= [imdivide(tmpRBC_Osc_Proj,1)];
matrixa(isnan(matrixa))=0;
A3=matrixa(1:4,1:4);
A4=mean(A3,"all");
B3=matrixa(5:8,1:4);
B4=mean(B3,"all");
C3=matrixa(1:4,5:8);
C4=mean(C3,"all");
D3=matrixa(5:8,5:8);
D4=mean(D3,"all");
OSC1 = [A4,B4;C4,D4];
disp('tmpRBC_Osc_Proj Avg in Quads')
disp(OSC1);
subplot(2,3,4)
imagesc(RBC2MemAmp.*Mask);axis square;axis off;clim([0 0.1]);
matrixa= [imdivide(RBC2MemAmp.*Mask,1)];
matrixa(isnan(matrixa))=0;
A5=matrixa(1:4,1:4);
A6=mean(A5,"all");
B5=matrixa(5:8,1:4);
B6=mean(B5,"all");
C5=matrixa(1:4,5:8);
C6=mean(C5,"all");
D5=matrixa(5:8,5:8);
D6=mean(D5,"all");
RBC2 = [A6,B6;C6,D6];
disp('RBC2MemAmp.*Mask Avg in Quads')
disp(RBC2);
subplot(2,3,5)
imagesc(RBC2Mem_Osc_Proj);axis square;axis off;clim([0 0.1])
subplot(2,3,6)
imagesc(tmpRBC2Mem_Osc_Proj);axis square;axis off;clim([0 0.1])
matrixa= [imdivide(tmpRBC2Mem_Osc_Proj,1)];
matrixa(isnan(matrixa))=0;
A7=matrixa(1:4,1:4);
A8=mean(A7,"all");
B7=matrixa(5:8,1:4);
B8=mean(B7,"all");
C7=matrixa(1:4,5:8);
C8=mean(C7,"all");
D7=matrixa(5:8,5:8);
D8=mean(D7,"all");
OSC2 = [A8,B8;C8,D8];
disp('tmpRBC2Mem_Osc_Proj Avg in Quads')
disp(OSC2);
y1=dist(RBC1,OSC1);
y2=dist(RBC2,OSC2);
disp('diff in top')
disp(y1);
disp('diff in bottom')
disp(y2);
catch
disp('Need to analyze both ims!')
end
end
0 Comments
Accepted Answer
DGM
on 16 May 2023
The fact that they aren't JPG isn't relevant. If you can read the image as an array of typical numeric class ('double','single','uint8','uint16','int16'), then you should be able to operate on it. I don't see anything that is preventing you from using imrotate() or rot90() to do whatever you need to do, but I also don't see where you're trying to do any rotation.
6 Comments
Walter Roberson
on 16 May 2023
How would having a file name help you to know how much to rotate the image by?
And is it possible that knowing the name of a variable inside a .mat file would allow you to deduce the required information?
DGM
on 16 May 2023
I'm not sure where this is going, but:
So far, I'm assuming that the rotations are all "in-plane" (i.e. as you would rotate a photo in photoshop). If you have a volumetric image and the axis of rotation is not parallel to the page axis, then you might use imrotate3(). If you're trying to reconstruct an image from projections, that's a different story.
More Answers (0)
See Also
Categories
Find more on 3-D Volumetric Image Processing in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!