" Local Otsu of a image passes through colfilt() " go through the code i'm getting error in this code

1 view (last 30 days)
function document_threshold()
iImage = imread('C:\Users\ChAnDrU\Documents\MATLAB\Test\1.jpg');
subplot(2, 2, 1);
imshow(iImage, []);title('Original Image');
[rows, columns, numberOfColorBands] = size(iImage);
if numberOfColorBands > 1
grayImage = iImage(:, :, 2);
end
subplot(2, 2, 2);
imshow(grayImage, []);title('Gray Image');
fun = @(x) LocalOtsu(x); A = im2double(grayImage); localThresh = colfilt(A, [15, 15],'sliding', fun); subplot(2, 2, 3); imshow(localThresh, []);title('Local Otsu Image');
function oneThresholdedPixel = LocalOtsu(grayImagePatch) oneThresholdedPixel = false; try [rows, columns] = size(grayImagePatch); middleRow = ceil(rows/2); middleColumn = ceil(columns/2); level = graythresh(grayImagePatch); % Threshold the center pixel only. oneThresholdedPixel = ~im2bw(grayImagePatch(middleRow, middleColumn), level); catch ME errorMessage = sprintf('Error in function %s() at line %d.\n\nError Message:\n%s', ... ME.stack(1).name, ME.stack(1).line, ME.message); fprintf(1, '%s\n', errorMessage); uiwait(warndlg(errorMessage)); end return;
%

Answers (0)

Categories

Find more on Deep Learning Toolbox in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!