フィルターのクリア

How can I recover my original image that I started with?

4 ビュー (過去 30 日間)
GHADAH AL-OBAIDI
GHADAH AL-OBAIDI 2021 年 6 月 5 日
編集済み: DGM 2023 年 5 月 1 日
How can I recover my original image back before the resize operations?
My code as below:
% Demo by Image Analyst
clc; % Clear the command window.
close all; % Close all figures (except those of imtool.)
clear; % Erase all existing variables. Or clearvars if you want.
workspace; % Make sure the workspace panel is showing.
format long g;
format compact;
fontSize = 20;
%--------------------------------------------------------------------------------------------------------
% READ IN IMAGE
folder = pwd;
baseFileName = 'pen_image.jpg';
grayImage = imread(baseFileName);
%--------------------------------------------------------------------------------------------------------
% Display the image.
subplot(2, 2, 1);
imshow(grayImage, []);
axis('on', 'image');
title('Original Gray Scale Image', 'FontSize', fontSize, 'Interpreter', 'None');
impixelinfo;
hFig = gcf;
hFig.WindowState = 'maximized'; % May not work in earlier versions of MATLAB.
drawnow;
% Get the dimensions of the image.
% numberOfColorChannels should be = 1 for a gray scale image, and 3 for an RGB color image.
[rows, columns, numberOfColorChannels] = size(grayImage);
if numberOfColorChannels > 1
% It's not really gray scale like we expected - it's color.
% Extract the red channel (so the magenta lines will be white).
grayImage = grayImage(:, :, 1);
end
% Reduce by half.
smallImage = imresize(grayImage, 0.5, 'nearest');
% Display the image.
subplot(2, 2, 2);
imshow(smallImage, []);
axis('on', 'image');
title('Small Image', 'FontSize', fontSize, 'Interpreter', 'None');
impixelinfo;
drawnow;
% Grow by a factor of two.
grownImage = imresize(smallImage, 2, 'nearest');
% Display the image.
subplot(2, 2, 3);
imshow(grownImage, []);
axis('on', 'image');
title('Grown Image', 'FontSize', fontSize, 'Interpreter', 'None');
impixelinfo;
drawnow;
% Find difference.
diffImage = imabsdiff(grayImage, grownImage);
% Display the image.
subplot(2, 2, 4);
imshow(diffImage, []);
axis('on', 'image');
title('Difference Image', 'FontSize', fontSize, 'Interpreter', 'None');
impixelinfo;
drawnow;
% Get the mean difference
meanDiff = mean(diffImage(:));
message = sprintf('The mean difference is %.2f gray levels', meanDiff);
uiwait(helpdlg(message));

回答 (1 件)

Sulaymon Eshkabilov
Sulaymon Eshkabilov 2021 年 6 月 5 日
編集済み: Sulaymon Eshkabilov 2021 年 6 月 5 日
As understood your question, the easy solution is recall the imported image data.
DATA1 =imread('MY_image.jpg'); % Original data
DATAp=DATA; % DATA for processing
...
% Compare the processed data against DATA1

カテゴリ

Help Center および File ExchangeRead, Write, and Modify Image についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by