We used matlab to create a simple image containing 1600 pixels. The masks of the image increased from 100 to 1650 and the quality of the linear reconstruction varied with the masks increasing. The flowchart of this week's progress can be seen on the following:
Our group writes a function to pass the parameter of the mask numbers so the function can call the parameter to do different reconstruction of different mask patterns. When the mask number is less than the total pixels of the image, the quality of linear reconstructed image becomes better as the mask number increased. If the mask number exceeds the pixels, the linear reconstruction can not complete.
The result can be seen on the following:
For the first part focusing on the reconstructed image and the pixels, the code can is attached on the following, it is divided into 2 parts, the main function and the combined function.
% test linear_rec(THzData, MaskData)
clear all;
% sample pattern
NP=40; % number of pixels
ima=zeros(NP);ima(:,1:3)=1; ima(:,14:16)=1; ima(:,24:26)=1; ima(:,38:40)=1; ima(1:3,:)=1;ima(14:16,:)=1;ima(24:26,:)=1; ima(38:40,:)=1; %establish a 32*32 zero matrix,sample pattern
figure(1),subplot(6,3,1),imagesc(ima), title('original image(NM)')
% simulate mask set data
NM=100; % nunmber of masks
x=1;
test(ima, NM, NP, x );
NM=600; % nunmber of masks
x=2;
test(ima, NM, NP, x );
NM=1200; % nunmber of masks
x=3;
test(ima, NM, NP, x );
NM=1600; % nunmber of masks
x=4;
test(ima, NM, NP, x );
NM=1650; % nunmber of masks
x=5;
test(ima, NM, NP, x );
Function
function test(ima, NM, NP, x ) %[ ima, imga, imgb, imgc ] =
subplot(6,3,3*x+1),imga=imagesc(ima);title('mask pattern')
subplot(6,3,3*x+2),imgb=imagesc(ima);title('combined')
a=3*x+1;
b=3*x+2;
c=3*x+3;
MaskData=zeros(NM,NP*NP);
for i=1:NM
temp=rand(NP); temp=temp>0.5;
MaskData(i,:)= temp(:);
%pause(0.1)
tempa=reshape(temp,NP,NP);%mask pattern
set(imga,'CData',tempa);
tempb=tempa.*ima; %combined patten
set(imgb,'CData',tempb);
end
THzData=MaskData*ima(:); % simulate terahertz measurement data
% reconstruction
newimg=linear_rec(THzData, MaskData); % call the reconstruciton function
% reifne and plot
newimg=squeeze(newimg);
newimg=newimg.*(newimg>0);
subplot(6,3,3*x+3),imgc=imagesc(newimg);title(['Reconstruction(NM=' , num2str(NM), ')']);
end
Problem 1
Problem 2
The error window in matlab is on the following:
没有评论:
发表评论