Filter löschen
Filter löschen

how to write data in new row in each iteration of for loop

4 Ansichten (letzte 30 Tage)
Manu Gowda
Manu Gowda am 16 Mär. 2022
Bearbeitet: Torsten am 16 Mär. 2022
I am reading images in loop and write data in new row in each iterartion in loop but not able to acheive that.
previous rows are formating to zeros in preceding iteration.
The code is
clc
clear all
close all
%imtool('ref1.jpg');% To know width of fuel
N = 5 %input('Enter the total number of frames N=');
w1 = 78 %input('width of fuel W1=');% entering the width of fuel by plot
w2 = 96 %input('width of fuel W2=');% entering the width of fuel by plot
T = 10 %input('Enter the value of threshold value T=');% entering the threshold value
imgdir = 'I:\Manu Gowda\images';
for i=1:N % reading frames
basename = sprintf('53 %04d.jpg', i);
im = imread(fullfile(imgdir, basename));% reading images from folder
% im=imread(['C:\Users\Nikhil\Desktop\Manu Gowda\images\chromcr' num2str(i) '.jpg']);% reading images from folder
[x,g]=size(im) % x is no of rows y is no coloums
y=g/3;% The size of rgb image is 3 times of normal image
for col=w1:w2
for i=x:-1:1
if im (i-1, col)-im(i,col)>=T
pos(N, col-w1+1)=i+1; % writing posion in excel from firt coloumn
%s=mean(pos);
break;
end
end
end
end
xlswrite('Positions.xlsx',pos)
The out put is
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
166 167 167 168 168 168 168 168 168 168 168 167 167 167 167 163 168 155 154

Antworten (2)

Manu Gowda
Manu Gowda am 16 Mär. 2022

Manu Gowda
Manu Gowda am 16 Mär. 2022

Kategorien

Mehr zu Images finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by