一、获取代码方式

获取代码方式1:
完整代码已上传我的资源:【图像处理】基于matlab GUI图像滤镜(马赛克+蓝色透镜+素描)【含Matlab源码 1145期】

获取代码方式2:
通过订阅紫极神光博客付费专栏,凭支付凭证,私信博主,可获得此代码。

备注:
订阅紫极神光博客付费专栏,可免费获得1份代码(有效期为订阅日起,三天内有效);

二、简介

1 图像马赛克
图像打码其实也是图像卷积操作中,空间域滤波的一种方式,用一定大小的滤波器对马赛克范围内像素进行操作。实现过程:将需要打马范围按照滤波器大小划分为多个区块,取滤波器范围内像素,求取均值,再将均值赋值给范围内每一个像素,滤波器再滑到下一个区块。

2 素描效果
PhotoShop里面把彩色图片打造成素描的效果仅仅需要几步操作:
1.去色(转为灰度图);
2.复制去色图层,并且反色(反色相当于Y(i,j) = 255 - X(i,j));
3.对反色图像进行高斯模糊;
4.模糊后的图像叠加模式选择颜色减淡效果。减淡公式:C = MIN( A +(A×B)/(255-B, 255),其中C为混合结果,A为去色后的像素点,B为高斯模糊后的像素点。

三、部分源代码

%
%2021/07/21
function varargout = filter_pic(varargin)
% FILTER_PIC MATLAB code for filter_pic.fig
%      FILTER_PIC, by itself, creates a new FILTER_PIC or raises the existing
%      singleton*.
%
%      H = FILTER_PIC returns the handle to a new FILTER_PIC or the handle to
%      the existing singleton*.
%
%      FILTER_PIC('CALLBACK',hObject,eventData,handles,...) calls the local
%      function named CALLBACK in FILTER_PIC.M with the given input arguments.
%
%      FILTER_PIC('Property','Value',...) creates a new FILTER_PIC or raises the
%      existing singleton*.  Starting from the left, property value pairs are
%      applied to the GUI before filter_pic_OpeningFcn gets called.  An
%      unrecognized property name or invalid value makes property application
%      stop.  All inputs are passed to filter_pic_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 filter_pic% Last Modified by GUIDE v2.5 21-Jun-2021 11:37:31% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name',       mfilename, ...'gui_Singleton',  gui_Singleton, ...'gui_OpeningFcn', @filter_pic_OpeningFcn, ...'gui_OutputFcn',  @filter_pic_OutputFcn, ...'gui_LayoutFcn',  [] , ...'gui_Callback',   []);
if nargin && ischar(varargin{1})gui_State.gui_Callback = str2func(varargin{1});
endif nargout[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});xw
elsegui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT% --- Executes just before filter_pic is made visible.
function filter_pic_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 filter_pic (see VARARGIN)% Choose default command line output for filter_pic
handles.output = hObject;global begin_down begin_start openflag ;
begin_down=0;
begin_start=0;
openflag=0;
set(handles.axes2,'visible','off');
% Update handles structure
guidata(hObject, handles);% UIWAIT makes filter_pic wait for user response (see UIRESUME)
% uiwait(handles.figure1);% --- Outputs from this function are returned to the command line.
function varargout = filter_pic_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;% --- Executes on button press in Open.
function Open_Callback(hObject, eventdata, handles)
% hObject    handle to Open (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
%
global  openflag begin_start;
[filename,pathname]=uigetfile({'*.bmp;*.jpg;*.gif','(*.bmp;*.jpg;*.gif)';'*.bmp','(*.bmp)';'*.jpg','(*.jpg)';'*.gif','(*.gif)';},'打开图片');
if isequal(filename,0)||isequal(pathname,0)return;
else
openflag=1;
begin_start=0;
RGB=imread([pathname,filename]);
RGB = imresize(RGB, [352 500]); %调整图像大小
cla(handles.axes1);
axes(handles.axes1);
imshow(RGB);
handles.image=RGB;
guidata(hObject,handles);
end% --- Executes on button press in Start.
function Start_Callback(hObject, eventdata, handles)
% hObject    handle to Start (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
global begin_start openflag ;if   openflag ;
begin_start=1;
handles.begin_point=get(gca,'currentpoint'); %先初始化开始的点的坐标,否则程序会报错
handles.axes1_point=get(handles.axes1,'Position'); %图片坐标情况
guidata(hObject,handles);
elseerrordlg('Please Open a File');
end
% --- Executes on mouse press over figure background, over a disabled or
% --- inactive control, or over an axes background.
function figure1_WindowButtonDownFcn(hObject, eventdata, handles)
% hObject    handle to figure1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
global begin_down begin_start;
pt_begine = get(hObject,'CurrentPoint');   %坐标合理
%disp(pt_begine(1,1));
if     begin_start...     &&pt_begine(1,1)>handles.axes1_point(1)...&& pt_begine(1,2)>handles.axes1_point(2) ...&& pt_begine(1,1)<handles.axes1_point(1)+ handles.axes1_point(3)...&& pt_begine(1,2)<handles.axes1_point(2)+handles.axes1_point(4)%disp(pt_begine(1,1));begin_down=1;%      %set(handles.axes2,'visible',on);
%      RGB=handles.image;
%      y0=pt_begine(1,2);
%      x0=pt_begine(1,1);
%      x0_width=100;
%      y0_height=100;
%      %RGB_filter=imcrop(RGB,[x0-handles.axes1_point(1) y0-handles.axes1_point(2) x0_width y0_height]);
%      %RGB_filter=imcrop(RGB,[x0-handles.axes1_point(1) handles.axes1_point(4)-(y0-handles.axes1_point(2)) x0_width y0_height]);
%      RGB_filter=imcrop(RGB,[(x0-x0_width-handles.axes1_point(1))  handles.axes1_point(4)-( y0+y0_height-handles.axes1_point(2))  x0_width y0_height]);
% %      Gray=rgb2gray(RGB_filter);
% %       R=RGB_filter(:,:,1); G=RGB_filter(:,:,2); B=RGB_filter(:,:,3);
% %      diff_R=20; diff_G=0; diff_B=0;  % 设置红、绿、蓝三种颜色提取阈值(越大越严格)
% %
% %     Image_B=RGB_filter;
% %     BP_R=RGB_filter(:,:,1);BP_G=RGB_filter(:,:,2);BP_B=RGB_filter(:,:,3);
% %     XYB=~((B-R)>diff_B&(B-G)>diff_B);  % 提取绿色条件是G分量与R、B分量差值大于设定
% %     Mask_B=Gray(XYB);  % 灰照片掩膜
% %     BP_R(XYB)=Mask_B; BP_G(XYB)=Mask_B; BP_B(XYB)=Mask_B;  % 使得非蓝色区域变为灰色
% %     Image_B(:,:,1)=BP_R; Image_B(:,:,2)=BP_G; Image_B(:,:,3)=BP_B;
%     RGB_filter(:,:,1)=0;
%     cla(handles.axes2);
%     %set(handles.axes2,'Position',[x0 y0-y0_height x0_width y0_height]);
%     set(handles.axes2,'Position',[x0-x0_width y0 x0_width y0_height]);
%     axes(handles.axes2);
%     imshow(RGB_filter);
% %     set(handles.axes2,'Position',[1 1 30 30]);
%     guidata(hObject,handles); elsebegin_down=0;
end% --- Executes on mouse motion over figure - except title and menu.
function figure1_WindowButtonMotionFcn(hObject, eventdata, handles)
% hObject    handle to figure1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)global begin_down;if begin_downpt_process  = get(hObject,'CurrentPoint');   %获取当前点坐标RGB=handles.image;x0=pt_process(1,1);y0=pt_process(1,2);x0_width=100;y0_height=100;if x0<handles.axes1_point(1)+x0_widthx0=handles.axes1_point(1)+x0_width;else if x0>handles.axes1_point(1)+handles.axes1_point(3)x0=handles.axes1_point(1)+handles.axes1_point(3);endendif y0<handles.axes1_point(2)y0=handles.axes1_point(2);else if y0>handles.axes1_point(2)+handles.axes1_point(4)-y0_height;y0=handles.axes1_point(2)+handles.axes1_point(4)-y0_height;endend%set(handles.axes2,'visible',off); %RGB_filter=imcrop(RGB,[x0-handles.axes1_point(1) y0-handles.axes1_point(2) x0_width y0_height]);%RGB_filter=imcrop(RGB,[x0-handles.axes1_point(1) handles.axes1_point(4)-(y0-handles.axes1_point(2)) x0_width y0_height]);set(handles.axes2,'visible','on');RGB_filter=imcrop(RGB,[(x0-x0_width-handles.axes1_point(1))  handles.axes1_point(4)-( y0+y0_height-handles.axes1_point(2))  x0_width y0_height]);%图像处理方法maflag=get( handles.ma_radiobutton,'Value' );blueflag=get( handles.blue_radiobutton,'Value');writeflag=get( handles.write_radiobutton,'Value');if maflagpix_grp = 10;height = size(RGB_filter,1);width = size(RGB_filter,2);mosaic = imresize(RGB_filter,[floor(height/pix_grp) floor(width/pix_grp)]);   RGB_filter = imresize(mosaic,[height width],'nearest');else if writeflagsize_info=size(RGB_filter);height=size_info(1);width=size_info(2);spec_img=zeros(height,width,3);%img_temp=rgb2gray(RGB_filter);for i=2:height-1for j=2:width-1spec_img(i,j,:)=double(RGB_filter(i-1,j-1,:))-double(RGB_filter(i+1,j+1,:))+128;endendRGB_filter= spec_img/255;else blueflag;RGB_filter(:,:,1)=0;end

四、运行结果



五、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)

【图像处理】基于matlab GUI图像滤镜(马赛克+蓝色透镜+素描)【含Matlab源码 1145期】相关推荐

  1. 【芯片识别】基于matlab GUI形态学PCB板芯片识别【含Matlab源码 1820期】

    ⛄一.获取代码方式 获取代码方式1: 完整代码已上传我的资源:[芯片识别]基于matlab GUI形态学 PCB板芯片识别[含Matlab源码 1820期] 点击上面蓝色字体,直接付费下载,即可. 获 ...

  2. 【大米粒计数】基于matlab GUI形态学大米粒颗粒识别【含Matlab源码 915期】

    ⛄一.获取代码方式 获取代码方式1: 完整代码已上传我的资源:[大米粒计数]基于matlab GUI形态学大米粒颗粒识别[含Matlab源码 915期] (https://download.csdn. ...

  3. 【光学】基于matlab GUI菲涅尔系数计算【含Matlab源码 1165期】

    ⛄一.获取代码方式 获取代码方式1: 完整代码已上传我的资源:[光学]基于matlab GUI菲涅尔系数计算[含Matlab源码 1165期] 点击上面蓝色字体,直接付费下载,即可. 获取代码方式2: ...

  4. 【电力预测】基于matlab GUI灰色模型电力负荷预测【含Matlab源码 769期】

    一.获取代码方式 获取代码方式1: 完整代码已上传我的资源: [电力负荷预测]基于matlab GUI灰色模型电力负荷预测[含Matlab源码 769期] 获取代码方式2: 通过订阅紫极神光博客付费专 ...

  5. 【图像修复】基于matlab GUI FMM+Criminisi算法彩色图像修复【含Matlab源码 1507期】

    一.FMM+Criminisi算法简介 1 FMM算法 FMM算法是由Telea在2004年提出的,主要思想是先处理待修复区域边缘的像素,然后逐步向内推进,直到所有空洞点修复完毕.设Λ为待修复区域, ...

  6. 【语音去噪】基于matlab GUI切比雪夫+椭圆形低通滤波器语音去噪【含Matlab源码 2198期】

    一.语音处理简介 1 语音信号的特点 通过对大量语音信号的观察和分析发现,语音信号主要有下面两个特点: ①在频域内,语音信号的频谱分量主要集中在300-3400Hz的范围内.利用这个特点,可以用一个防 ...

  7. 基于matlab的串口通信,基于Matlab GUI的单片机串口与PC的通信 附源码

    我也是最近学习单片机和MATLAB的小白平时在看学习的时候 下载了一些有价值的参考文献 概述采用51单片机,atmel的STC89C52RC芯片,主要用到的是七段数码管用来做一个时钟,程序编写软件为k ...

  8. 【功能超全】基于OpenCV车牌识别停车场管理系统软件开发【含python源码+PyqtUI界面+功能详解】-车牌识别python 深度学习实战项目

    车牌识别基础功能演示 摘要:车牌识别系统(Vehicle License Plate Recognition,VLPR) 是指能够检测到受监控路面的车辆并自动提取车辆牌照信息(含汉字字符.英文字母.阿 ...

  9. 简单物联网应用——基于老人居家声音监测系统(全!含完整源码、详细注释、测试结果、设计过程、视频详细教程)

    简单物联网应用设计与实现--基于老人居家声音监测系统 概述 设计内容: 采用标准的物联网三层架构, 感知层为可以检测声音数据并且实现无线发送的传感器节点: 网络层主要使用无线 WiFi: 应用层中, ...

  10. 【身份证识别】基于matlab GUI形态学二代身份证识别系统【含Matlab源码 947期】

    ⛄一.身份证号码识别简介 1 引言 作为居民身份的象征,身份证是居民身份的唯一标识,它已成为生活中必不可少的证件.在火车站.酒吧等公共场所,流动人口大人员复杂,警察需要对公民的身份证进行核对,排除可疑 ...

最新文章

  1. sql server面试题
  2. 如何用java完成Excel快速的导入导出
  3. 300*4=1200
  4. 关于Jupyter Notebook默认起始目录设置无效的解决方法
  5. 表迁移工具的选型-复制ibd的方法-传输表空间
  6. docker redis重启_Docker解决傻瓜式安装软件
  7. UVA 1524 - Hot or Cold?(数学)
  8. 使用百度链的智能合约来落地公司业务场景
  9. 【对比】新、旧QC七大手法的异同
  10. iwebshop功能添加——邮箱邀请注册增加积分
  11. android 自定义menu菜单按键功能
  12. ldo低压差线性稳压器电路解析
  13. 百度云 文字识别 身份证识别
  14. 深入理解MDL元数据锁
  15. CentOS7搭建nextcloud创建私有云盘
  16. 开源企业内部沟通协作平台 ENTBOOST 发布1.21版本
  17. el-table中的树形结构
  18. smtp发送邮件用了授权码还是出现535 Error: authentication failed
  19. python豆瓣历史评分_基于Python的豆瓣电影评分查询器
  20. matlab稀疏矩阵三元法,数据结构——稀疏矩阵三元组表示法+算法详解

热门文章

  1. 【2018.9.26】K-D Tree详解
  2. 利用Python进行数据分析——重要的Python库介绍
  3. javascript高级编程笔记04(基本概念)
  4. 去掉Scala的糖衣(4) -- Type Aliase
  5. ps aux 中的状态说明
  6. 在存储过程中动态创建临时表
  7. 树莓派使用 USB 摄像头做网络监控
  8. 190521每日一句
  9. unity数组或链表需要空间很大赋值与调用
  10. 如何阅读科研文献-------------一点思考与总结