필터 지우기
필터 지우기

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

조회 수: 4 (최근 30일)
Manu Gowda
Manu Gowda 2022년 3월 16일
편집: Torsten 2022년 3월 16일
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

답변 (2개)

Manu Gowda
Manu Gowda 2022년 3월 16일

Manu Gowda
Manu Gowda 2022년 3월 16일

카테고리

Help CenterFile Exchange에서 Images에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by