2016年2月15日星期一

Week 2 Common Image with Its Reconstruction

On week 2, our group researched on the effect of the numbers of the masks on the linear reconstructed image and RGB combine of a real colorful image. 

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

Our group meet the problem this week. We tried to solve the RGB combination but meet some problem with the code. The problem of the result can be seen on the following:


Problem 1


Problem 2

The error window in matlab is on the following:



2016年2月9日星期二

Week 1 Single Color Image and Its Combine Pattern

   In week 1, our group had a meeting about the second year project. The material was a paper whose name is Terahertz pulsed spectroscopic imaging using optimized binary masks authored by Dr. Y.C. Shen. We learned some basic knowledge about this project, the function to process the images. The image can be processed by the points on the following:

  • For one specific image with fixed pixels, the first thing is to determine the numbers of the pixels. 
  • Divide the image into several parts.
  • Create the mask pattern with pixels. 
  • Combined the original image with the mask pattern. 
  • Reconstruct the image and output the reconstructed image. 

   On the first week, our group changed the numbers of the mask pattern to find the result of the reconstruction of the original image. We found that with the increasement of the mask patterns, the quality becomes better which illustrates the relationship between the mask patterns and the reconstructed image is linear. 
    The result of the program with the mask pattern size 90, 180, 270 is attached at the end.  

    The flow chart is on the following:


The flowchart of the image processing
The code for the first week can be seen on the following:
% 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(2,2,1),imagesc(ima), title('original image')
% simulate mask set data
NM=90; % nunmber of masks

% mask data
MaskData=zeros(NM,NP*NP);
subplot(2,2,2),im1=imagesc(ima);title('mask pattern')
subplot(2,2,3),im2=imagesc(ima);title('combined')
for i=1:NM
    temp=rand(NP); temp=temp>0.5;
    MaskData(i,:)= temp(:);
    pause(0.1)
    temp1=reshape(temp,NP,NP);%mask pattern
    set(im1,'CData',temp1);
    temp=temp1.*ima; %combined patten
    set(im2,'CData',temp);
end
% THz data
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);
figure(1);subplot(2,2,4),imagesc(newimg);% display the reconstructed image
title('Results of Linear Reconstruction');




The result of 90 Mask Pattern

The result of 180 Mask Pattern



The result of 270 Mask Pattern