0% found this document useful (0 votes)
50 views

%noise Mixtures: 2/2/12 Visualization-3D Surface Modeling With Noise Mixture

The document describes using MATLAB code to generate a 3D surface model of a circuit board with noise mixtures. The code loads an image of a circuit board, applies Gaussian filters to detect edges, and adds two levels of Gaussian noise to simulate surface roughness. Background and foreground noise are also added to simulate color variations. The resulting noisy image is used to modulate the Z height values and generate a color-coded 3D MAT5 surface file for visualization.
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
50 views

%noise Mixtures: 2/2/12 Visualization-3D Surface Modeling With Noise Mixture

The document describes using MATLAB code to generate a 3D surface model of a circuit board with noise mixtures. The code loads an image of a circuit board, applies Gaussian filters to detect edges, and adds two levels of Gaussian noise to simulate surface roughness. Background and foreground noise are also added to simulate color variations. The resulting noisy image is used to modulate the Z height values and generate a color-coded 3D MAT5 surface file for visualization.
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

2/2/12

Visualization-3D surface modeling with noise mixture

%noise mixtures
clear all; dx=50/72; % (microns per pixel)physical distance between pixels dy=dx; dz=50; % (microns per pixel intensity) physical distance for image intensity

%input mask image


A_bmp=double(imread('SimpleCircuit.bmp')); % load example.bmp image Ar=A_bmp(:,:,1); Ag=A_bmp(:,:,2); Ab=A_bmp(:,:,3); Amask=(Ar+Ag+Ab)/3; [My Nx]=size(Amask); figure(1) imagesc(Amask) colormap gray; axis image; title('Circuit feature map') %print -djpeg fig1 Cmask=binarize(Amask); figure(2) imagesc(Cmask) colormap gray; axis image; title('Re-binarized feature map') %print -djpeg fig2

% gaussian filter
sigma=4; x=1:Nx; x=x-Nx/2; y=1:My; y=y-My/2; hgauss=gaperture(sigma,sigma,x,y); hgauss=fftshift(hgauss); % shift to put origin at the corners figure(3) imagesc(hgauss) colormap gray; axis image; title('Gaussian filter centred for circular convolution') %print -djpeg fig3

% filter the large image


Dmask=real(ifft2(fft2(Cmask).*fft2(hgauss))); Dmask=Dmask-min(min(Dmask)); Dmask=Dmask./max(max(Dmask))

% update the Cmask to include the new edges of the lines


I1=find(Dmask>0.01); Cmask(I1)=1;

file:///C:/Users/Karthik/Desktop/Matlab Files/html/Visualization-3D surface modeling with noise mixture.html

2/2/12

Visualization-3D surface modeling with noise mixture

figure(4) imagesc(Cmask) colormap gray; axis image; title('Filtered Map') %print -djpeg fig4

% add roughness with two levels of noise


noise=rand(My,Nx); sigma=0.1; hgaussnoise=gaperture(sigma,sigma,x,y); Hgaussnoise=fft2(fftshift(hgaussnoise)); % shift to put origin at the corners noiseF=real(ifft2(fft2(noise).*Hgaussnoise)); noiseF=noiseF-min(min(noiseF)); noiseF=noiseF/max(max(noiseF)); noiseF=noiseF;

% background surface noise


noise0=noiseF.*0.005;

% foreground surface noise


noise1=noiseF.*0.02; I0=find(Cmask<=0.1); I1=find(Cmask>0.1); Dmaskb4=Dmask; Dmask(I0)=Dmask(I0)+noise0(I0); Dmask(I1)=Dmask(I1)+noise1(I1); figure(5) imagesc(Dmask) colormap gray; axis image; title('Filtered map plus Surface Noise') %print -djpeg fig5

% create red noise and thresh % BACKGROUND NOISE BLOBS


sigma=10; x=1:Nx; x=x-Nx/2; y=1:My; y=y-My/2; hgauss2=gaperture(sigma,sigma,x,y); figure(6) imagesc(hgauss2); colormap gray; axis image; title('Background Colored Noise Filter') %print -djpeg fig6 Hgauss2=fft2(fftshift(hgauss2)); % shift to put origin at the corners

% background noise blobs


noise2=real(ifft2(fft2(noise).*Hgauss2));
file:///C:/Users/Karthik/Desktop/Matlab Files/html/Visualization-3D surface modeling with noise mixture.html

2/2/12

Visualization-3D surface modeling with noise mixture

noise2=noise2-min(min(noise2)); noise2=noise2/max(max(noise2)); eta=0.8; I2=find(noise2<eta); I2B=find((noise2>=eta)&(Cmask<=0.1)|(Dmask>=0.1)); noise2(I2)=eta; noise2=noise2-eta; noise2=noise2.*(1-Cmask); figure(7) imagesc(noise2); colormap gray; axis image; title('Background Colored Noise') %print -djpeg fig7

% FOREGROUND noise blobs


sigma=15; x=1:Nx; x=x-Nx/2; y=1:My; y=y-My/2; hgauss3=gaperture(sigma,sigma,x,y); figure(8) imagesc(hgauss3); colormap gray; axis image; title('Foreground Colored Noise Filter') %print -djpeg fig8 Hgauss3=fft2(fftshift(hgauss3)); % shift to put origin at the corners noise3=real(ifft2(fft2(noise).*Hgauss3)); noise3=noise3-min(min(noise3)); noise3=noise3/max(max(noise3)); eta=0.3; I3=find(noise3>eta); noise3(I3)=eta; noise3=noise3-eta; noise3=noise3./abs(min(min(noise3))); noise3=noise3.*Cmask; noise3=1+noise3; figure(9) imagesc(noise3); colormap gray; axis image; title('Foreground Colored Noise') %print -djpeg fig9

% mix in the noise


Ib4=find(((Dmaskb4>0.1)&(noise3<1))|((Dmaskb4>0.1)&(noise2>0))); Dmask(Ib4)=Dmaskb4(Ib4); Dmask=Dmask+noise2; % use additive noise to position spatter on substrate Dmask=Dmask.*noise3; % use multiplication to cut away circuit lines

file:///C:/Users/Karthik/Desktop/Matlab Files/html/Visualization-3D surface modeling with noise mixture.html

2/2/12

Visualization-3D surface modeling with noise mixture

figure(10) imagesc(Dmask); colormap gray; axis image; title('Final QR chart image') %print -djpeg fig10

% create a mat5 3D surface Albedo8=uint8(zeros(My,Nx)); % gold color 255, 215, 0 % copper color 184,115,51 imageC=uint8(zeros(My,Nx,3)); % red Albedo8(I0)=184; Albedo8(I1)=255; Albedo8(I2B)=255; imageC(:,:,1)=Albedo8; %green Albedo8(I0)=115; Albedo8(I1)=215; Albedo8(I2B)=215; imageC(:,:,2)=Albedo8; % blue Albedo8(I0)=51; Albedo8(I1)=0; Albedo8(I2B)=0; imageC(:,:,3)=Albedo8; % make all pixels high quality value of 20 imageI=uint8(20*ones(My,Nx,3)); index=1; xw=zeros(My,Nx); yw=xw; zw=yw; zw=Dmask*dz; for x=1:Nx for y=1:My xw(index)=(x-1)*dx; yw(index)=(My-y)*dy; index=index+1; end; end; mat5prefix = 'Circuits3D'; result= mat5CIXYZwrite2011(mat5prefix,imageC,imageI,xw,yw,zw);

file:///C:/Users/Karthik/Desktop/Matlab Files/html/Visualization-3D surface modeling with noise mixture.html

You might also like