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

6 visualizaciones (últimos 30 días)
GHADAH AL-OBAIDI
GHADAH AL-OBAIDI el 5 de Jun. de 2021
Editada: DGM el 1 de Mayo de 2023
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));

Respuestas (1)

Sulaymon Eshkabilov
Sulaymon Eshkabilov el 5 de Jun. de 2021
Editada: Sulaymon Eshkabilov el 5 de Jun. de 2021
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

Categorías

Más información sobre Read, Write, and Modify Image en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by