⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 stegocombine.m

📁 stegenogrpahy in matlab based on dwt
💻 M
📖 第 1 页 / 共 2 页
字号:
% file name 'stegocombine.m'% Run through Matlab% By: Louis Casillas, oxaric@gmail.com% Input:% tree_path.jpg (RGB)% wolverine.jpg (RGB)% Output:% displays these two images combined and the restored wolverine % image pulled from the combined image% How:% resizes wolverine.jpg to the size of tree_path.jpg,% adds the resized wolverine image to tree_path.jpg by weighted values% specified by WEIGHTED_COMBINE_VALUE:% combined_image = tree_path + (wolverine_resized * WEIGHTED_COMBINE_VALUE)% then tries to restore the wolverine image by subtracting the original% tree_path.jpg values from the combined_image values and dividing by% WEIGHTED_COMBINE_VALUE:% restored_wolverine_image = (tree_path - combined_image) / WEIGHTED_COMBINE_VALUE% the percent used to multiply the wolverine.jpg color values by before% adding them to tree_path.jpg% 1.0 = 100%WEIGHTED_COMBINE_VALUE = 0.01;% false => only display combined image and restored image% true => display all imagesDISPLAY_INTERMEDIATE_IMAGES = false;% set DISPLAY_TESTING_IMAGES to a number below to run those tests% extra tests will show how the wolverine image is restored from the % combined image for these 3 cases:% 0 => no extra tests% 1 => if the combined image is resized% 2 => if the combined image is stored as a heavily compressed .jpg% 3 => if the combined image has added noise% 4 => show all testsDISPLAY_TESTING_IMAGES = 4;% load the imagesoriginal_tree_path_image = imread( 'tree_path.jpg' );original_wolverine_image = imread( 'wolverine.jpg' );% grab the x and y resolution for tree_path.jpgtree_path_x_size = size( original_tree_path_image, 2 );tree_path_y_size = size( original_tree_path_image, 1 );% grab the x and y resolution for wolverine.jpgoriginal_wolverine_x_size = size( original_wolverine_image, 2 );original_wolverine_y_size = size( original_wolverine_image, 1 );if DISPLAY_INTERMEDIATE_IMAGES    % display the original tree_path.jpg    figure, imshow( original_tree_path_image ); title( 'Original - tree_path.jpg' );    % display the original wolverine.jpg    figure, imshow( original_wolverine_image ); title( 'Original - wolverine.jpg' );end% resize wolverine.jpg to be the same same as tree_path.jpgresized_wolverine_image = imresize( original_wolverine_image, [tree_path_y_size, tree_path_x_size] );if DISPLAY_INTERMEDIATE_IMAGES        % display the resized wolverine.jpg    figure, imshow( resized_wolverine_image ); title( 'Resized Wolverine' );end% create a blank image the same size as tree_path.jpg% this will store the new image that is a combination of tree_path.jpg and% wolverine.jpgcombined_image = zeros( tree_path_y_size, tree_path_x_size, 3 );% add tree_path.jpg and wolverine.jpg but only give the pixels in% the resized wolverine.jpg a weighted value determined by% WEIGHTED_COMBINE_VALUEfor x_value = 1:tree_path_x_size    for y_value = 1:tree_path_y_size        combined_image( y_value, x_value, 1 ) = original_tree_path_image( y_value, x_value, 1 ) + (resized_wolverine_image( y_value, x_value, 1 ) * WEIGHTED_COMBINE_VALUE);        combined_image( y_value, x_value, 2 ) = original_tree_path_image( y_value, x_value, 2 ) + (resized_wolverine_image( y_value, x_value, 2 ) * WEIGHTED_COMBINE_VALUE);        combined_image( y_value, x_value, 3 ) = original_tree_path_image( y_value, x_value, 3 ) + (resized_wolverine_image( y_value, x_value, 3 ) * WEIGHTED_COMBINE_VALUE);    endend% force the combined image color values to be between 0 and 255combined_image = uint8( combined_image );% display the combined tree_path.jpg and wolverine.jpgfigure, imshow( combined_image ); title( 'Weight Combined Image' );% create a blank image the same size as tree_path.jpgwolverine_restored_big_image = zeros( tree_path_y_size, tree_path_x_size, 3 );% take the values in the combined image and subtract them from the original% tree_path.jpg values, this will give the values that were added to% tree_path.jpg above, then divide these values by WEIGHTED_COMBINE_VALUE in order to try % to get the original values in wolverine.jpgfor x_value = 1:tree_path_x_size    for y_value = 1:tree_path_y_size        wolverine_restored_big_image( y_value, x_value, 1 ) = ( combined_image( y_value, x_value, 1 ) - original_tree_path_image( y_value, x_value, 1 ) ) / WEIGHTED_COMBINE_VALUE;        wolverine_restored_big_image( y_value, x_value, 2 ) = ( combined_image( y_value, x_value, 2 ) - original_tree_path_image( y_value, x_value, 2 ) ) / WEIGHTED_COMBINE_VALUE;        wolverine_restored_big_image( y_value, x_value, 3 ) = ( combined_image( y_value, x_value, 3 ) - original_tree_path_image( y_value, x_value, 3 ) ) / WEIGHTED_COMBINE_VALUE;    endend% force wolverine restored image color values to be between 0 and 255wolverine_restored_big_image = uint8( wolverine_restored_big_image );if DISPLAY_INTERMEDIATE_IMAGES        % display the restored wolverine.jpg that is still the size of tree_path.jpg    figure, imshow( wolverine_restored_big_image ); title( 'Restored Wolverine - Tree Path Size' );end% resize wolverine_restored_big_image to the size of the original wolverine.jpgwolverine_restored_image = imresize( wolverine_restored_big_image, [ original_wolverine_y_size , original_wolverine_x_size ] );% display the restored wolverine image that is the original wolverine.jpg sizefigure, imshow( wolverine_restored_image ); title( 'Restored Wolverine - Original Size' );% compute the Peak Signal-to-Noise Ratio (PSNR) between the original% wolverine.jpg and the wolverine image restored from the combined image% The bigger the PSNR the closer the two images are to being exactly the% same and if the PSNR is infinity the images are exactly the same% If not infinity values of 30 to 50 are very good and values above 50 are% excellent/amazing% Displayed in the Matlab command windowmean_square_error = sum( sum( sum( ( original_wolverine_image - wolverine_restored_image ).^2 ) ) ) / double( original_wolverine_x_size * original_wolverine_y_size * 3 );disp(' ')disp('The PSNR between the original wolverine.jpg and the restored wolverine taken from the combined image:')PSNR = 10 * log10( ( 255 )^2 / mean_square_error )% DISPLAY_TESTING_IMAGES =% 0 => no extra tests% 1 => if the combined image is resized% 2 => if the combined image is stored as a heavily compressed .jpg% 3 => if the combined image has added noise% 4 => show all testsif (DISPLAY_TESTING_IMAGES ~= 0) && (DISPLAY_TESTING_IMAGES < 5)    % try to restore the wolverine image from the combined image when the     % combined image is resized    if (DISPLAY_TESTING_IMAGES == 1) || (DISPLAY_TESTING_IMAGES == 4)            % the percent to resize the combined image        PERCENT_TO_RESIZE = 0.4;        % resize the combined image        resized_combined_image = imresize( combined_image, [ tree_path_y_size * PERCENT_TO_RESIZE, tree_path_x_size * PERCENT_TO_RESIZE ] );                if DISPLAY_INTERMEDIATE_IMAGES                        % display the resized combined image            figure, imshow( resized_combined_image ); title( 'Combine Image - Resized' );        end                % restore the resized combined image to its original size        restored_combined_image = imresize( resized_combined_image, [tree_path_y_size, tree_path_x_size ] );        if DISPLAY_INTERMEDIATE_IMAGES            % display the combined image that has been returned to its            % original size            figure, imshow( restored_combined_image ); title( 'Combined Image - Resized to Original Size' );        end                % try to get the original values in wolverine.jpg        for x_value = 1:tree_path_x_size            for y_value = 1:tree_path_y_size                wolverine_restored_big_image( y_value, x_value, 1 ) = ( restored_combined_image( y_value, x_value, 1 ) - original_tree_path_image( y_value, x_value, 1 ) ) / WEIGHTED_COMBINE_VALUE;                wolverine_restored_big_image( y_value, x_value, 2 ) = ( restored_combined_image( y_value, x_value, 2 ) - original_tree_path_image( y_value, x_value, 2 ) ) / WEIGHTED_COMBINE_VALUE;                wolverine_restored_big_image( y_value, x_value, 3 ) = ( restored_combined_image( y_value, x_value, 3 ) - original_tree_path_image( y_value, x_value, 3 ) ) / WEIGHTED_COMBINE_VALUE;            end        end

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -