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

7 views (last 30 days)
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

Answers (2)

Manu Gowda
Manu Gowda on 16 Mar 2022

Manu Gowda
Manu Gowda on 16 Mar 2022

Categories

Find more on Images in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!