Averaging the values of grayscale intensity for each image?
3 ビュー (過去 30 日間)
古いコメントを表示
Is there a way in my script to just get each individual image's ControltoTest without overwriting it every time it analyzes an image for a value and just do the average mean of the values?
RC = input('Are all the images cropped already? Y/N','s');
if strcmpi(RC, 'y')
uncropped=1;
else
uncropped=0;
end
%Asks user to select the folder containing the calibration set inside.
CalFolder = uigetdir('Please select the calibration folder containing the images to calibrate.');
if ~isdir(CalFolder)
errorMessage = sprintf('Error: The following folder does not exist:\n%s', CalFolder);
uiwait(warndlg(errorMessage));
return;
end
%Adds the folder pathname to the top of the MATLAB search path list so it can find it first.
addpath(CalFolder);
%Returns a string containing the full file pathname and then shows the
%filenames of the pictures inside the folder.
calfilePattern = fullfile(CalFolder, '*.jpg');
caljpegFiles = dir(calfilePattern);
%Creates a cell array with the dimensions of: the quantity of pictures in
%the folder by 1
LFAcalarr=cell(length(caljpegFiles),1);
%Stores the filenames of the pictures to use in the script.
for i=1:length(caljpegFiles)
LFAcalarr{i}=caljpegFiles(i).name;
end
%Insert file names (without extensions) into LFAfile for processing needs
%all images in folder.
for m=1:length(LFAcalarr)
%Add the file extension and look for the file
LFACalibration = imread(LFAcalarr{m});
%Uncropped set to 0 means that the image must still be manually
%cropped
if(uncropped==0)
%Image will appear in upper panel.
%Manually crop by drawing a box around the test and control lines
%Make sure the control line is in the left half of the crop window
%and the test line is in the right half of the crop window
subplot(3,1,1);
LFAGrayCal = imcrop(rgb2gray(LFACalibration));
close all;
else
LFAGrayCal = rgb2gray(LFACalibration);
end
%Get the number of pixels along the x axis
CropWidthCal = size(LFAGrayCal,2);
%Convert to 1-Dimension by averaging along the columns
%In Grayscale, low values correspond to dark and high values to white
%Take complement and add 255 so dark values correspond to high signals
LFA1DCal=imcomplement(mean(LFAGrayCal,1))+255;
%Split the left matrix containing control line
%Split right matrix containing test line
LFAControlCal = LFA1DCal(1:fix(0.5*CropWidthCal));
LFATestCal = LFA1DCal(fix(0.5*CropWidthCal)+1:CropWidthCal);
%Locate the control line by finding the maximum and get value
[CalControlLineMax, CalControlLineLocation] = max(LFAControlCal);
%Calibration is on
%Locate test line by finding the maximum and get value
[TestLineMaxCal,TestLineLocationCal] = max(LFATestCal);
TestLineLocationCal = TestLineLocationCal + fix(.5*CropWidthCal);
%Calculate distance between control and test line
ValControlToTest=TestLineLocationCal-CalControlLineLocation;
ControlToTest = mean(ValControltoTest);
end
_
0 件のコメント
採用された回答
Image Analyst
2014 年 7 月 9 日
Make it an array
ControlToTest(m) = ..................
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Convert Image Type についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!