Skip to content
Snippets Groups Projects
Commit adba3887 authored by Angeline Aguinaldo's avatar Angeline Aguinaldo
Browse files

Completed check errors for all functions.

Need to population function executions for:
- ReduceImage.m
- RegionGrowing.m
- Segment.m
- TileImage.m
parent 7ee7ab36
No related tags found
No related merge requests found
......@@ -43,7 +43,15 @@ function histogram = NormalizedHistogram(imageIn,numBins,min,max)
end
function histogram = lclNormalizedHistogram(imageIn,numBins,min,max)
if(numBins == 0 )
if nargin < 1 || nargin > 5
error('Incorrect number of inputs!')
end
if length(size(imageIn))>3
error('Image can have a maximum of three dimensions!')
end
if isempty(numBins) || ~exist('numBins') || numBins == 0
histogram = imhist(imageIn(imageIn > min)) ./ sum(imhist(imageIn(imageIn > min)));
else
histogram = imhist(imageIn(imageIn > min),numBins) ./ sum(imhist(imageIn(imageIn > min),numBins));
......
......@@ -43,8 +43,30 @@ function imageOut = OtsuThresholdFilter(imageIn,alpha)
end
function imageOut = lclOtsuThresholdFilter(imageIn,alpha)
if nargin < 1 || nargin > 2
error('Incorrect number of inputs!')
end
if length(size(imageIn)) > 3
error('Image can have a maximum of three dimensions!')
end
if ~isa(alpha, 'double')
error('Alpha needs to be a single double!')
end
type = [];
if ~isa(imageIn, 'double')
type = class(imageIn);
imageIn = im2double(imageIn);
end
threshold = graythresh(imageIn);
imageOut = imageIn > threshold*alpha;
imageOut = im2uint8(imageOut);
if ~isempty(type)
imageOut = ImUtils.ConvertType(imageOut, type);
end
end
......@@ -43,6 +43,18 @@ function threshold = OtsuThresholdValue(imageIn)
end
function threshold = lclOtsuThresholdValue(imageIn)
if nargin ~= 1
error('Incorrect number of inputs!')
end
if length(size(imageIn)) > 3
error('Image can have a maximum of three dimensions!')
end
if ~isa(imageIn, 'double')
imageIn = im2double(imageIn);
end
threshold = graythresh(imageIn);
end
......@@ -43,6 +43,19 @@ function imageOut = ReduceImage(imageIn,reductionFactor,method)
end
function imageOut = lclReduceImage(imageIn,reductionFactor,method)
if nargin ~= 3
error('Incorrect number of inputs!')
end
if length(size(imageIn)) > 3
error('Image can have a maximum of three dimensions!')
end
if numel(reductionFactor) ~=3 || ~isa(reductionFactor, 'double')
error('Reduction has to be an array of three doubles!')
end
end
......@@ -43,6 +43,27 @@ function maskOut = RegionGrowing(imageIn,kernel,mask,threshold,allowConnections)
end
function maskOut = lclRegionGrowing(imageIn,kernel,mask,threshold,allowConnections)
if nargin ~= 5
error('Incorrect number of inputs!')
end
if legnth(size(imageIn)) > 3
error('Image can have a maximum of three dimensions!')
end
if length(size(kernel)) < 1 || length(size(kernel)) > 3
error('Kernel can only be either 1-D, 2-D, or 3-D')
end
if length(size(mask)) ~= length(size(imageIn))
error('Mask must be same dimensions as image!')
end
if ~isa(mask, 'logical')
error('Mask must be of logical types!')
end
end
......@@ -43,6 +43,23 @@ function imageOut = Segment(imageIn,alpha,MorphClosure)
end
function imageOut = lclSegment(imageIn,alpha,MorphClosure)
if nargin ~=3
error('Incorrect number of inputs!')
end
if length(size(imageIn)) > 3
error('Image can have a maximum of three dimensions!')
end
if ~isa(alpha, 'double')
error('Alpha has to be a single double!')
end
if numel(MorphClosure) ~= 3|| ~isa(MorphClosure, 'double')
error('Morph closure has to be an array of three doubles')
end
end
......@@ -43,6 +43,27 @@ function imageOut = StdFilter(imageIn,Neighborhood)
end
function imageOut = lclStdFilter(imageIn,Neighborhood)
if nargin < 1 || nargin > 2
error('Incorrect number of inputs!')
end
if length(size(imageIn)) > 3
error('Image can have a maximum of three dimensions!')
end
if numel(Neighborhood) ~= 3 || ~isa(Neighborhood, 'double')
error('Neighborhood has to be an array of three doubles!')
end
type = [];
if ~isa(imageIn, 'double')
type = class(imageIn);
end
imageOut = stdfilt(imageIn, Neighborhood);
if ~isempty(type)
imageOut = ImUtils.ConvertType(imageOut, type);
end
end
......@@ -43,6 +43,18 @@ function imageOut = ThresholdFilter(imageIn,threshold)
end
function imageOut = lclThresholdFilter(imageIn,threshold)
if nargin ~=2
error('Incorrect number of inputs!')
end
if length(size(imageIn)) > 3
error('Image can have a maximum of three dimensions!')
end
if ~isa(threshold, 'double')
error('Threshold needs to be a single double!')
end
bw_logical = imageIn > threshold;
type = class(imageIn);
......
......@@ -48,6 +48,23 @@ function imageOut = TileImage(imageIn,roiStart,roiSize)
end
function imageOut = lclTileImage(imageIn,roiStart,roiSize)
if narginn ~= 3
error('Incorrect number of inputs!')
end
if length(size(imageIn)) > 3
error('Image can have a maximum of three dimensions!')
end
if numel(roiStart) ~= 3 || ~isa(roiStart, 'double')
error('Starts must be an array of three doubles!')
end
if numel(roiSize) ~= 3 || ~isa(roiSize, 'double')
error('Sizes must be an array of three doubles!')
end
end
......@@ -43,6 +43,14 @@ function variance = Variance(imageIn)
end
function variance = lclVariance(imageIn)
if narin ~= 1
error('Incorrect number of inputs!')
end
if length(size(imageIn)) >3
error('Image can have a maximum of three dimensions!')
end
variance = var(imageIn);
end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment