一、直方图医学图像处理简介
直方图统计:灰度直方图是关于灰度级分布的函数,是对图像中灰度级分布的统计。灰度直方图是将数字图像中的所有像素,按照灰度值的大小,统计其出现的频率。图像直方图由于其计算代价较小,且具有图像平移、旋转、缩放不变性等众多优点,广泛地应用于图像处理的各个领域。
图像处理基础教程链接
1 【基础教程】基于matlab图像处理(表示方法+数据结构+基本格式+类型转换+读取+点运算+代数运算)【含Matlab源码 834期】
2 【基础教程】基于matlab图像处理(读写+显示+运算+转换+变换+增强+滤波+分析+统计)【含Matlab源码 144期】
3 【基础教程】基于matlab图像增强+复原+分割【含Matlab源码 056期】
二、部分源代码
function varargout = Histogram_Processing_System(varargin)
% HISTOGRAM_PROCESSING_SYSTEM M-file for Histogram_Processing_System.fig
% HISTOGRAM_PROCESSING_SYSTEM, by itself, creates a new HISTOGRAM_PROCESSING_SYSTEM or raises the existing
% singleton*.
%
% H = HISTOGRAM_PROCESSING_SYSTEM returns the handle to a new HISTOGRAM_PROCESSING_SYSTEM or the handle to
% the existing singleton*.
%
% HISTOGRAM_PROCESSING_SYSTEM('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in HISTOGRAM_PROCESSING_SYSTEM.M with the given input arguments.
%
% HISTOGRAM_PROCESSING_SYSTEM('Property','Value',...) creates a new HISTOGRAM_PROCESSING_SYSTEM or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before Histogram_Processing_System_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to Histogram_Processing_System_OpeningFcn via varargin.
%
% *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one
% instance to run (singleton)".
%
% See also: GUIDE, GUIDATA, GUIHANDLES
% Edit the above text to modify the response to help Histogram_Processing_System
% Last Modified by GUIDE v2.5 14-Sep-2012 10:37:41
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @Histogram_Processing_System_OpeningFcn, ...
'gui_OutputFcn', @Histogram_Processing_System_OutputFcn, ...
'gui_LayoutFcn', [] , ...
'gui_Callback', []);
if nargin && ischar(varargin{1})
gui_State.gui_Callback = str2func(varargin{1});
end
if nargout
[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT
% --- Executes just before Histogram_Processing_System is made visible.
function Histogram_Processing_System_OpeningFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% varargin command line arguments to Histogram_Processing_System (see VARARGIN)
% Choose default command line output for Histogram_Processing_System
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes Histogram_Processing_System wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = Histogram_Processing_System_OutputFcn(hObject, eventdata, handles)
% varargout cell array for returning output args (see VARARGOUT);
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Get default command line output from handles structure
varargout{1} = handles.output;
% --------------------------------------------------------------------
function Untitled_1_Callback(hObject, eventdata, handles)
% hObject handle to Untitled_1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --------------------------------------------------------------------
function Untitled_2_Callback(hObject, eventdata, handles)
% hObject handle to Untitled_2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --------------------------------------------------------------------
function Untitled_3_Callback(hObject, eventdata, handles)
% hObject handle to Untitled_3 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --------------------------------------------------------------------
function Untitled_4_Callback(hObject, eventdata, handles)
% hObject handle to Untitled_4 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --------------------------------------------------------------------
function Untitled_5_Callback(hObject, eventdata, handles)
% hObject handle to Untitled_5 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --------------------------------------------------------------------
function Untitled_6_Callback(hObject, eventdata, handles)
% hObject handle to Untitled_6 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global h
[filename, pathname] = uigetfile({'*.*'},'Open file');
str=[pathname filename];
[im,map]=imread(str); %读取原图像
axes(handles.axes1);cla;
%显示原图像
imshow(im,map);
if length(size(im))==3
if size(map)==0
f_HSI=rgb2hsi(im);
h=f_HSI(:,:,3); %提取rgb图像亮度分量
else
h=ind2gray(im,map); %索引图像转化为灰度图像
end
else
h=im;
end
set(handles.uipanel4,'visible','on');
set(handles.axes1,'visible','on');
set(handles.text1,'visible','on','string','原图');
%获取原图像信息
info=imfinfo(str)
%获取原图像信息
str1=sprintf('文件路径: %s\n',pathname);
str2=sprintf('图像名称: %s\n',filename);
str3=sprintf('图像格式: %s\n',info.Format);
str4=sprintf('图像类型: %s\n',info.ColorType);
str5=sprintf('文件大小: %dbit\n',info.FileSize);
str6=sprintf('图像宽度: %d\n',info.Width);
str7=sprintf('图像高度: %d\n',info.Height);
str8=sprintf('图像位深: %d\n',info.BitDepth);
%显示所获取的原图像信息
str0=[str1,str2,str3,str4,str5,str6,str7,str8];
set(handles.text7,'string',str0);
axes(handles.axes3);cla;
axes(handles.axes2);cla;
axes(handles.axes4);cla;
set(handles.axes2,'visible','off');
set(handles.axes4,'visible','off');
set(handles.text2,'visible','off');
set(handles.text3,'visible','off');
set(handles.text4,'visible','off');
set(handles.uipanel2,'visible','off');
set(handles.uipanel3,'visible','off');
% --------------------------------------------------------------------
function Untitled_7_Callback(hObject, eventdata, handles)
% hObject handle to Untitled_7 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global g
[filename pathname]=uiputfile(...
{'*.jpg','JPEG-files(*.jpg)'; ...
'*.png', 'PNG-files (*.png)';...
'*.tif', 'TIFF-files (*.tif)'}); %打开保存地址
str=[pathname filename];
imwrite(g,str); %按固定格式保存处理后图像
三、运行结果
四、matlab版本及参考文献
1 matlab版本
2014a
2 参考文献
[1] 蔡利梅.MATLAB图像处理——理论、算法与实例分析[M].清华大学出版社,2020.
[2]杨丹,赵海滨,龙哲.MATLAB图像处理实例详解[M].清华大学出版社,2013.
[3]周品.MATLAB图像处理与图形用户界面设计[M].清华大学出版社,2013.
[4]刘成龙.精通MATLAB图像处理[M].清华大学出版社,2015.
[5]陈浩,方勇,朱大洲,王成,陈子龙.基于蚁群算法的玉米植株热红外图像边缘检测[J].农机化研究. 2015,37(06)