Using xlswrite() to store the output from regionprops()
Show older comments
Hi everyone,
I am using the following code to output the results from a regionprops operation:
clc
clear all
files = dir('*.jpg');
for k = 1:numel(files)
rgb = imread(files(k).name);
rgb = imcrop(rgb,[1 21 1279 988]);
cform = makecform('srgb2lab');
lab_Image = applycform(im2double(rgb),cform);
rgb = lab_Image(:, :, 3);
rgb = adapthisteq(rgb, 'NumTiles', [9 9], ...
'Cliplimit', 0.001);
rgb = edge(rgb,'canny');
se90 = strel('line',2,90);
se75 = strel('line',2,75);
se60 = strel('line',2,60);
se45 = strel('line',2,45);
se30 = strel('line',2,30);
se0 = strel('line',2,0);
rgb = imdilate(rgb,[se90 se75 se60 se45 se30 se0]);
% Use regionprops to generate area and solodity information.
s = regionprops(rgb,'area', 'Solidity');
areas = cat(1,s.Area);
solidity = cat(1,s.Solidity);
xlswrite('trialdata.xlsx', areas,'Sheet1');
xlswrite('trialdata.xlsx', solidity,'Sheet2');
end
The data is currently stored in the excel file on the first column (A:A). Unfortunately, it doesn't capture as to which image the measurements belong to.
I was wondering if someone could please help me out with how to output the file name for whcih each entry belongs to. I think what I am looking for is a format like:
In Sheet1,
- Column A = name of the image
- Column B = regionprops measurement (area)
- Column C = regionprops measurement (solidity)Thanks in advance.
Cheers
Accepted Answer
More Answers (0)
Categories
Find more on Surface and Mesh Plots in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!