필터 지우기
필터 지우기

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 CenterFile Exchange에서 Read, 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