0% found this document useful (0 votes)
34 views6 pages

File in

This document contains MATLAB code for image processing tasks. It defines functions to open image files, display images, perform operations like grayscale conversion, adjusting brightness, and combining images. Buttons are created to call these functions and display the results in figure windows. The code loads images, performs grayscale and brightness adjustments, and adds images together to demonstrate basic image processing operations.

Uploaded by

huyn
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 DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
34 views6 pages

File in

This document contains MATLAB code for image processing tasks. It defines functions to open image files, display images, perform operations like grayscale conversion, adjusting brightness, and combining images. Buttons are created to call these functions and display the results in figure windows. The code loads images, performs grayscale and brightness adjustments, and adds images together to demonstrate basic image processing operations.

Uploaded by

huyn
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 DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 6

close all;

clear all;
clc;
%--------------------------------------------
TRANGNHO=figure ( 'name','BAITAP_XULYANH',...
'color',[0 .3 .22],...
'numbertitle','off',...
'menubar','none',...
'position',[0 0 1024 768]);
%--------------------------------------------

uicontrol('Style','Text',...
'String','TRÖÔØNG ÑAÏI HOÏC VAÊN HIEÁN',...
'position',[200 650 600 50],...
'Backgroundcolor',[0 .3 .22],...
'FontName','VNI-Times',...
'FontSize',20,...
'FontWeight','bold',...
'HorizontalAlignment','center',...
'Foregroundcolor',[0 1 1]);
% -------------------------------------------------

uicontrol('Style','Text',...
'String','KHOA ÑIEÄN TÖÛ VIEÃN THOÂNG',...
'position',[300 600 450 40],...
'Backgroundcolor',[0 .3 .22],...
'FontName','VNI-Times',...
'FontSize',20,...
'FontWeight','bold',...
'HorizontalAlignment','center',...
'Foregroundcolor',[0 1 1]);
%------------------------------------------------------------
uicontrol('Style','Text',...
'String','SVTH:TRAÀN BAÙ HUYØNH 07EV019',...
'position',[122 40 450 70],...
'FontName','VNI-Times',...
'FontSize',15,...
'FontWeight','bold',...
'HorizontalAlignment','left',...
'Backgroundcolor',[0 .3 .22],...
'Foregroundcolor',[.935 0 .478]);
uicontrol('Style','Text',...
'String','LÔÙP: 07E1',...
'position',[122 0 350 70],...
'FontName','VNI-Times',...
'FontSize',15,...
'FontWeight','bold',...
'HorizontalAlignment','left',...
'Backgroundcolor',[0 .3 .22],...
'Foregroundcolor',[.935 0 .478]);

uicontrol('Style','Text',...
'String','BAØI TAÄP:XÖÛ LYÙ AÛNH',...
'position',[390 150 450 70],...
'FontName','VNI-Times',...
'FontSize',15,...
'FontWeight','bold',...
'HorizontalAlignment','left',...
'Backgroundcolor',[0 .3 .22],...
'Foregroundcolor',[.935 0 .478]);
%---------------------------------------------------------------------
uicontrol('Style','pushbutton',...
'String','Next',...
'position',[750 10 90 50],...
'FontName','VNI-Times',...
'FontSize',16,...
'FontWeight','bold',...
'HorizontalAlignment','right',...
'Backgroundcolor',[0 .3 .22],...
'Foregroundcolor',[.435 0 .978],...
'callback','baitaptt');
uicontrol('Style','pushbutton',...
'String','Exit',...
'position',[900 10 90 50],...
'FontName','VNI-Times',...
'FontSize',16,...
'FontWeight','bold',...
'HorizontalAlignment','right',...
'Backgroundcolor',[0 .3 .22],...
'Foregroundcolor',[.435 0 .978],...
'callback','close');
%-------------------------------------------------------
axes('Position',[.31 .4 .37 .37],...
'XTick',[],...
'YTick',[],...
'Xlim',[0 4],... %gioi han truc x trong doan [0 4]
'Ylim',[0 4],... %gioi han truc y trong doan [0 4]
'Box','on');
imshow('logo.jpg');

LÀM XÁM ẢNH


%chuong trinh lam xam anh
clc;

xam=rgb2gray(Anh_goc1);

axes( ...
'Units','normalized', ...
'Position',[0.59 0.55 0.40 0.40], ...
'BusyAction','Queue','Interruptible','off',...
'Ydir','reverse',...
'Xlim',[.5 128.5],...
'Ylim',[.5 128.5],...
'CLim',[0 1],...
'XTick',[],'YTick',[], ...
'Box','on');
imshow(xam);
BÀI TẬP TT
% chuong trinh tao 6 cua so de nhap anh
clc;
pos=[ 0 0 1024 768]
fg=figure(...
'numbertitle','off',...
'units','pixel',...
'color',[0.7 0.1 0.4],...
'menubar','none',...
'name','giaodien',...
'position',pos,...
'Visible','on',...
'backingstore','on');

%----------------------------------------------------------------------
uicontrol( 'Style','PushButton',...
'FontName','VNI-Times',...
'Backgroundcolor','c',...
'foregroundcolor','black',...
'FontSize',11,...
'FontWeight','bold',...
'HorizontalAlignment','left',...
'String','I1',...
'Position',[10,400,50,25],...
'callback','cuasochonanh1');
%-----------------------------------------------------------------
uicontrol( 'Style','PushButton',...
'FontName','VNI-Times',...
'Backgroundcolor','c',...
'foregroundcolor','black',...
'FontSize',11,...
'FontWeight','bold',...
'HorizontalAlignment','left',...
'String','I2',...
'Position',[500,400,50,25],...
'callback','cuasochonanh2');
%------------------------------------------------------------------
uicontrol( 'Style','PushButton',...
'FontName','VNI-Times',...
'Backgroundcolor','c',...
'foregroundcolor','black',...
'FontSize',11,...
'FontWeight','bold',...
'HorizontalAlignment','left',...
'String','I1+I2',...
'Position',[900,400,50,25],...
'callback','conghaianh');
%------------------------------------------------------------------
uicontrol( 'Style','PushButton',...
'FontName','VNI-Times',...
'Backgroundcolor','c',...
'foregroundcolor','black',...
'FontSize',11,...
'FontWeight','bold',...
'HorizontalAlignment','left',...
'String','Gray I1',...
'Position',[10,50,70,25],...
'callback','lamxamanh');
uicontrol( 'Style','PushButton',...
'FontName','VNI-Times',...
'Backgroundcolor','c',...
'foregroundcolor','black',...
'FontSize',11,...
'FontWeight','bold',...
'HorizontalAlignment','left',...
'String','xam*1.5',...
'Position',[500,50,70,25],...
'callback','lamsanganhxam');

uicontrol( 'Style','PushButton',...
'FontName','VNI-Times',...
'Backgroundcolor','c',...
'foregroundcolor','black',...
'FontSize',11,...
'FontWeight','bold',...
'HorizontalAlignment','left',...
'String','xam*0.5',...
'Position',[900,50,70,25],...
'callback','lamtoianhxam');

CỘ NG 2 ẢNH
%chuong trinh cong anh
clc;

cong=(Anh_goc2)+(Anh_goc1);

axes( ...
'Units','normalized', ...
'Position',[0.59 0.55 0.40 0.40], ...
'BusyAction','Queue','Interruptible','off',...
'Ydir','reverse',...
'Xlim',[.5 128.5],...
'Ylim',[.5 128.5],...
'CLim',[0 1],...
'XTick',[],'YTick',[], ...
'Box','on');
imshow(cong);

CỬA SỔ 2
[filename, pathname] = uigetfile( ...
{ '*.*', 'Any Files (*.*)'}, ...
'chonanh');
[path,name,ext,versn] = fileparts([pathname '\' filename]);
Anh_goc = imread([pathname filename]);
axes( ...
'Units','normalized', ...
'Position',[0.29 0.55 0.40 0.40], ...
'BusyAction','Queue','Interruptible','off',...
'Ydir','reverse',...
'Xlim',[.5 128.5],...
'Ylim',[.5 128.5],...
'CLim',[0 1],...
'XTick',[],'YTick',[], ...
'Box','on');
imshow(Anh_goc);
CỬA SỔ CHỌN ẢNH
[filename, pathname] = uigetfile( ...
{ '*.*', 'Any Files (*.*)'}, ...
'chonanh');
[path,name,ext,versn] = fileparts([pathname '\' filename]);
Anh_goc = imread([pathname filename]);
axes( ...
'Units','normalized', ...
'Position',[0.01 0.55 0.40 0.40], ...
'BusyAction','Queue','Interruptible','off',...
'Ydir','reverse',...
'Xlim',[.5 128.5],...
'Ylim',[.5 128.5],...
'CLim',[0 1],...
'XTick',[],'YTick',[], ...
'Box','on');
imshow(Anh_goc);
CỬA SỔ CHỌN ẢNH 1
[filename, pathname] = uigetfile( ...
{ '*.*', 'Any Files (*.*)'}, ...
'chonanh');
[path,name,ext,versn] = fileparts([pathname '\' filename]);
Anh_goc1 = imread([pathname filename]);
imshow(Anh_goc1)

LÀM TỐI ẢNH XÁM 2


%chuong trinh lam anh xam toi di
clc;
%%
% % I1=imread('E:\hinh\du lich van thanh\PA220142.jpg');
% I2=imread('E:\hinh\du lich van thanh\PA220131.jpg');
B=xam*0.5;

axes( ...
'Units','normalized', ...
'Position',[0.59 0.55 0.40 0.40], ...
'BusyAction','Queue','Interruptible','off',...
'Ydir','reverse',...
'Xlim',[.5 128.5],...
'Ylim',[.5 128.5],...
'CLim',[0 1],...
'XTick',[],'YTick',[], ...
'Box','on');
imshow(B);

LÀM SÁNG ẢNH XÁM


%chuong trinh lam anh xam sang len
clc;
%%
% % I1=imread('E:\hinh\du lich van thanh\PA220142.jpg');
% I2=imread('E:\hinh\du lich van thanh\PA220131.jpg');
A=xam*1.5;

axes( ...
'Units','normalized', ...
'Position',[0.59 0.55 0.40 0.40], ...
'BusyAction','Queue','Interruptible','off',...
'Ydir','reverse',...
'Xlim',[.5 128.5],...
'Ylim',[.5 128.5],...
'CLim',[0 1],...
'XTick',[],'YTick',[], ...
'Box','on');
imshow(A);

CỘ NG 2 ẢNH
%chuong trinh cong 2 anh I1+I2
I1=imread('D:\hinh\DAM SEN\IMG_0619.JPG');
I1=imread('D:\hinh\DAM SEN\IMG_0624.JPG');
I=I1+I2;
imshow(I)
CỬA SỔ CHỌN ẢNH 2
[filename, pathname] = uigetfile( ...
{ '*.*', 'Any Files (*.*)'}, ...
'chonanh');
[path,name,ext,versn] = fileparts([pathname '\' filename]);
Anh_goc2 = imread([pathname filename]);
imshow(Anh_goc2);

You might also like