Filter löschen
Filter löschen

Summation problem while lopping of an image

1 Ansicht (letzte 30 Tage)
Nimit Jain
Nimit Jain am 29 Jun. 2016
Kommentiert: Nimit Jain am 29 Jun. 2016
close all
clear all
a = imread('lena.tif');
figure, imshow(a);
[r,c] = size(a);
sum = 0;
fileID = fopen('exp.txt','w');
fileID1 = fopen('totalValue.txt', 'w');
for i=1:r
for j=1:c
value = a(i,j);
sum = sum + value;
fprintf(fileID,'%d\n', value);
fprintf(fileID1, '%d\n' , sum);
disp(a(i,j));
end
end
fclose(fileID);
fclose(fileID1);
Total some coming is 255. I am trying to get the per pixel value. Image size is 255x255.
Please help.

Akzeptierte Antwort

Walter Roberson
Walter Roberson am 29 Jun. 2016
value = double( a(i,j) );
and please rename your variable sum as you are interfering with the use of the important function sum which is likely to cause you problems as you keep developing your program (including the problem that it confuses the people you are asking to read your code.)
  1 Kommentar
Nimit Jain
Nimit Jain am 29 Jun. 2016
Thanks Walter now it is working fine. Actually from the total the sum I am trying to get the size contribution by each pixel (x,y) in the image.
Suppose I have 255x255 image and the image size is 400 KB. Now I am trying to calculate each pixel (x,y) size contribution (even in terms of RGB).
Can you please help me out in this.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Convert Image Type finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by