12
HC VIN CÔNG NGHBƯU CHÍNH VIỄN THÔNG KHOA: VIN THÔNG 2 NGÀNH: ĐIỆN T- VIN THÔNG Môn : XLÍ HÌNH NH Đề Tài : Tách ảnh đen trang ra thành 2 mặt phng LSB và MSB GVHD : Ts Nguyn Thanh Bình LP : L11CQVT-N SVTH : Nhóm 9

Báo cáo nhóm 9

  • Upload
    thanhyu

  • View
    402

  • Download
    2

Embed Size (px)

Citation preview

HỌC VIỆN CÔNG NGHỆ BƯU CHÍNH VIỄN THÔNG KHOA: VIỄN THÔNG 2

NGÀNH: ĐIỆN TỬ - VIỄN THÔNG

Môn : XỬ LÍ HÌNH ẢNH

Đề Tài : Tách ảnh đen trang ra thành 2 mặt phẳng LSB và MSB

GVHD : Ts Nguyễn Thanh Bình

LỚP : L11CQVT-N

SVTH : Nhóm 9

Danh sách sinh viên thực hiện :

Nguyễn Thành Tài : Nhóm Trưởng

Lí Trấn Đông

Huỳnh Bảo Phú

Lê Hồng Thành

Nguyễn Hoàng Duy Minh

Hồ Minh Quân

Tách ảnh trắng đen ra hai phần LSB và MSB

Ảnh gốc :

ảnh kết quả :

MSB LSB

Để chạy chương trình ta thực hiện các bước sau :

Bước 1 : copy file bit_plane_32 ra một thư mục khác

Bước 2 : nhấn double clich vào files trên sau khi cài đạt xong

Bước 3 : chay file bit_plane_32.exe

Bước 4 : xuất hiện hộp thoại

Bước 5 : nhấn vào open chọn đường dẫn của files hình ành

Bước 6 : nhấn vào nút lsb để xem mặt phẳng ảnh - sau do ành sẽ xuất hiện :

Bước 7 : nhấn vào nút msb để xem mặt phẳng ảnh – sau đó ảnh xuất hiện

Code để chương trình chạy : function varargout = bit(varargin)

% BIT MATLAB code for bit.fig

% BIT, by itself, creates a new BIT or raises the existing

% singleton*.

%

% H = BIT returns the handle to a new BIT or the handle to

% the existing singleton*.

%

% BIT('CALLBACK',hObject,eventData,handles,...) calls the local

% function named CALLBACK in BIT.M with the given input arguments.

%

% BIT('Property','Value',...) creates a new BIT or raises the

% existing singleton*. Starting from the left, property value pairs are

% applied to the GUI before bit_OpeningFcn gets called. An

% unrecognized property name or invalid value makes property application

% stop. All inputs are passed to bit_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 bit

% Last Modified by GUIDE v2.5 15-Oct-2012 19:47:14

% Begin initialization code - DO NOT EDIT

gui_Singleton = 1;

gui_State = struct('gui_Name', mfilename, ...

'gui_Singleton', gui_Singleton, ...

'gui_OpeningFcn', @bit_OpeningFcn, ...

'gui_OutputFcn', @bit_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 bit is made visible.

function bit_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 bit (see VARARGIN)

% Choose default command line output for bit

handles.output = hObject;

% Update handles structure

guidata(hObject, handles);

% UIWAIT makes bit wait for user response (see UIRESUME)

% uiwait(handles.figure1);

% --- Outputs from this function are returned to the command line.

function varargout = bit_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)

[filename, pathname, filterindex]=uigetfile( ...

{'*.jpg','JPEG — Joint Photographic Experts Group (*.jpg)'; ...

'*.png','PNG — Portable Network Graphics (*.png)'; ...

'*.bmp','BMP — Windows Bitmap (*.bmp)';...

'*.*','All file (*.*)'}, ...

'Open picture');

link = strcat(pathname,filename);

set(handles.edit_link,'String',link);

% --- Executes on button press in source.

function source_Callback(hObject, eventdata, handles)

% hObject handle to source (see GCBO)

% eventdata reserved - to be defined in a future version of MATLAB

% handles structure with handles and user data (see GUIDATA)

link = get(handles.edit_link,'String');

image_rgb = imread(link);

figure(1);

imshow(image_rgb);

% --- Executes on button press in gray.

function gray_Callback(hObject, eventdata, handles)

% hObject handle to gray (see GCBO)

% eventdata reserved - to be defined in a future version of MATLAB

% handles structure with handles and user data (see GUIDATA)

link = get(handles.edit_link,'String');

image_rgb = imread(link);

image_gray = rgb2gray(image_rgb);

figure(1);

imshow(image_gray);

% --- Executes on button press in lsb.

function lsb_Callback(hObject, eventdata, handles)

% hObject handle to lsb (see GCBO)

% eventdata reserved - to be defined in a future version of MATLAB

% handles structure with handles and user data (see GUIDATA)

link = get(handles.edit_link,'String');

image_rgb = imread(link);

image_gray = rgb2gray(image_rgb);

image_bit_lsb = bitget(image_gray,1);

figure(1);

imshow(image_bit_lsb,[]);

% --- Executes on button press in msb.

function msb_Callback(hObject, eventdata, handles)

% hObject handle to msb (see GCBO)

% eventdata reserved - to be defined in a future version of MATLAB

% handles structure with handles and user data (see GUIDATA)

link = get(handles.edit_link,'String');

image_rgb = imread(link);

image_gray = rgb2gray(image_rgb);

image_bit_msb = bitget(image_gray,8);

figure(1);

imshow(image_bit_msb,[]);

function edit_link_Callback(hObject, eventdata, handles)

% hObject handle to edit_link (see GCBO)

% eventdata reserved - to be defined in a future version of MATLAB

% handles structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of edit_link as text

% str2double(get(hObject,'String')) returns contents of edit_link as a double

% --- Executes during object creation, after setting all properties.

function edit_link_CreateFcn(hObject, eventdata, handles)

% hObject handle to edit_link (see GCBO)

% eventdata reserved - to be defined in a future version of MATLAB

% handles empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.

% See ISPC and COMPUTER.

if ispc && isequal(get(hObject,'BackgroundColor'),

get(0,'defaultUicontrolBackgroundColor'))

set(hObject,'BackgroundColor','white');

end

% --- Executes on button press in lsb_msb.

function lsb_msb_Callback(hObject, eventdata, handles)

% hObject handle to lsb_msb (see GCBO)

% eventdata reserved - to be defined in a future version of MATLAB

% handles structure with handles and user data (see GUIDATA)

link = get(handles.edit_link,'String');

image_rgb = imread(link);

image_gray = rgb2gray(image_rgb);

image_bit_lsb = bitget(image_gray,1);

image_bit_msb = bitget(image_gray,8);

lsb_msb=image_bit_msb + image_bit_lsb;

figure(1);

imshow(lsb_msb,[]);