Filter löschen
Filter löschen

How to find energy of an image

2 Ansichten (letzte 30 Tage)
Dhrubajyoti Das
Dhrubajyoti Das am 9 Mai 2014
Kommentiert: Image Analyst am 9 Jan. 2016
I want to find the energy of an image using the formula given in the attached image. Please help.
  4 Kommentare
Walter Roberson
Walter Roberson am 9 Jan. 2016
You do not show the error message.
What is xpy?
size() is going to return p and q as scalars, but in your for loop you are using p as a vector. Your "for j" loop also does not refer to j at all, so there is no point in using a loop there if the code is correct.
Image Analyst
Image Analyst am 9 Jan. 2016
If "i have a doubt not related to this question" then you should start your own question so we don't bug Dhrubajyoti Das with emails about updates to his question. In that question, I will answer with how you used the size function incorrectly.

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Image Analyst
Image Analyst am 9 Mai 2014
Assuming F is the Fourier Transform, try fft2().
  2 Kommentare
Dhrubajyoti Das
Dhrubajyoti Das am 9 Mai 2014
but sir, how to find the value of 't' as shown in the attached image.
Image Analyst
Image Analyst am 9 Mai 2014
F = fft2(grayImage) -- did you try it? Did you try anything like the code below:
clc; % Clear the command window.
close all; % Close all figures (except those of imtool.)
imtool close all; % Close all imtool figures if you have the Image Processing Toolbox.
clear; % Erase all existing variables. Or clearvars if you want.
workspace; % Make sure the workspace panel is showing.
format long g;
format compact;
fontSize = 24;
%===============================================================================
% Read in a standard MATLAB gray scale demo image.
folder = fileparts(which('cameraman.tif')); % Determine where demo folder is (works with all versions).
baseFileName = 'cameraman.tif';
% Get the full filename, with path prepended.
fullFileName = fullfile(folder, baseFileName);
% Check if file exists.
if ~exist(fullFileName, 'file')
% File doesn't exist -- didn't find it there. Check the search path for it.
fullFileNameOnSearchPath = baseFileName; % No path this time.
if ~exist(fullFileNameOnSearchPath, 'file')
% Still didn't find it. Alert user.
errorMessage = sprintf('Error: %s does not exist in the search path folders.', fullFileName);
uiwait(warndlg(errorMessage));
return;
end
end
grayImage = imread(fullFileName);
% Get the dimensions of the image.
% numberOfColorBands should be = 1.
[rows, columns, numberOfColorBands] = size(grayImage);
if numberOfColorBands > 1
% It's not really gray scale like we expected - it's color.
% Convert it to gray scale by taking only the green channel.
grayImage = grayImage(:, :, 2); % Take green channel.
end
% Display the original gray scale image.
subplot(2, 2, 1);
imshow(grayImage, []);
title('Original Grayscale Image', 'FontSize', fontSize);
% Enlarge figure to full screen.
set(gcf, 'Units', 'Normalized', 'OuterPosition', [0 0 1 1]);
% Give a name to the title bar.
set(gcf, 'Name', 'Demo by ImageAnalyst', 'NumberTitle', 'Off')
% Take the Fourier Transform.
F = fft2(grayImage);
realF = log(real(F));
% Display the original gray scale image.
subplot(2, 2, 2);
imshow(realF, []);
title('Original Grayscale Image', 'FontSize', fontSize);
% Sum up the values.
magImage = abs(F).^2;
energy = sum(magImage(:))

Melden Sie sich an, um zu kommentieren.

Community Treasure Hunt

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

Start Hunting!

Translated by