赞
踩
本设计主要针对指针式仪表的数字化读数的研究,提高读取效率和读数的准确性.以MATLAB为载体对图像进行仿真处理,通过设备采集图片,对图像进行表盘定位、图像预处理、边缘检测、Hough变换等操作,识别出指针的位置,得出指针所在直线的斜率,并结合角度与量程的关系
%%% greyscale-greyscale mutimodal image fusion (anatomical-anatomical)
clear
% clc
addpath('utilities');
%% fusion problem
fusion_mods = 'CT-T2';
% fusion_mods = 'T1-T2';
%% parameters
opts.k = 5;
opts.rho = 10; % penalty parameter
opts.plot = false; % plot decomposition components
%% loading input images
I1 = double(imread(['Source_Images\' fusion_mods '_A.png']))/255;
if size(I1,3)>1, I1 = rgb2gray(I1); end
I2 = double(imread(['Source_Images\' fusion_mods '_B.png']))/255;
if size(I2,3)>1, I2 = rgb2gray(I2); end
%% performing decomposition and fusion
n = 64; % number of atoms in dictionaries
b = 8; % patch size
D0 = DCT(n,b); % initializing the dictionaries with DCT matrices
tic;
[~,~,Ie1,Ie2,D1,D2,A1,A2] = perform_Corr_Ind_Decomp(I1,I2,D0,D0,opts); % Deocomposition
IF = Fuse_grey(Ie1,Ie2,D1,D2,A1,A2); % Fusion
toc % runtime
%% results
F = uint8(IF*255);
imwrite(F,['Results\' fusion_mods '_F.png']);
figure(23)
subplot 131
imshow(I1,[])
xlabel('I_1')
subplot 132
imshow(I2,[])
xlabel('I_2')
subplot 133
imshow(IF,[])
xlabel('I^F')
function status = utPlot(this,ax,h,robj)
% add response of model h.Model's output robj.OutputName to all axes ax.
% ax is usually a single handle, but may be two entries in case a non-GUI
% plot is updated as a result of pressing "Apply" button.
% Copyright 2005-2006 The MathWorks, Inc.
status = true;
[range,y,thisnl] = h.generateNLData(robj,this.NumSample);
if isempty(y)
status = false;
return;
end
if h.isActive
vis = 'on';
else
vis = 'off';
end
if ~robj.is2D
% 3D (mesh) plot
%Alternative: surf(axk,range{1},range{2},y'); shading(axk,'interp')
thisCol = h.Color;
[irow,icol] = size(y);
colmat = [];
colmat(:,:,1) = repmat(thisCol(1),icol,irow);
colmat(:,:,2) = repmat(thisCol(2),icol,irow);
colmat(:,:,3) = repmat(thisCol(3),icol,irow);
for k = 1:length(ax)
mesh(ax(k),range{1},range{2},y',colmat,'tag',h.ModelName,'userdata',class(thisnl),'vis',vis);
%hold(ax(k),'on')
end
else
% 2D plot
for k = 1:length(ax)
plot(ax(k),range{1},y,'Color',h.Color,'tag',h.ModelName,'userdata',class(thisnl),'vis',vis);
%hold(ax(k),'on')
end
end
%%% color-greyscale mutimodal image fusion (functional-anatomical)
clear
% clc
addpath('utilities');
%% fusion problem
% fusion_mods = 'T2-PET';
% fusion_mods = 'T2-TC';
fusion_mods = 'T2-TI';
% fusion_mods = 'Gad-PET';
%% parameters
opts.k = 5; % maximum nnonzero entries in sparse vectors
opts.rho = 10; % optimization penalty term
opts.plot = false; % plot decomposition components
%% loading input images
I1rgb = double(imread(['Source_Images\' fusion_mods '_A.png']))/255;
I1ycbcr = rgb2ycbcr(I1rgb);
I1 = I1ycbcr(:,:,1);
I2 = double(imread(['Source_Images\' fusion_mods '_B.png']))/255;
if size(I2,3)>1, I2 = rgb2gray(I2); end
%% performing decomposition and fusion
n = 32; b = 8;
D0 = DCT(n,b); % initializing the dictionaries with DCT matrices
tic;
[~,~,Ie1,Ie2,D1,D2,A1,A2] = perform_Corr_Ind_Decomp(I1,I2,D0,D0,opts); % Decomposition
[IF, IF_int] = Fuse_color(Ie2,Ie1,D2,D1,A2,A1,I1ycbcr); % Fusion
toc; % runtime
%% results
F = uint8(IF*255);
imwrite(F,['Results\' fusion_mods '_F.png']);
figure(23)
subplot 131
imshow(I1rgb,[])
xlabel('I_1')
subplot 132
imshow(I2,[])
xlabel('I_2')
subplot 133
imshow(IF,[])
xlabel('I^F')
%% dictionary atoms
% ID1 = displayPatches(D1);
% ID2 = displayPatches(D2);
%
% figure(37)
% subplot 121
% imshow(ID1)
% xlabel('D1')
% subplot 122
% imshow(ID2)
% xlabel('D2')
%% dictionary atoms
% ID1 = displayPatches(D1);
% ID2 = displayPatches(D2);
%
% figure(37)
% subplot 121
% imshow(ID1)
% xlabel('D1')
% subplot 122
% imshow(ID2)
% xlabel('D2')
[1]谢伟等. "基于MATLAB的指针式仪表识别的仿真设计." 南方农机.
部分理论引用网络文献,若有侵权联系博主删除。
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。