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

1 回表示 (過去 30 日間)
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;
%

回答 (0 件)

カテゴリ

Help Center および File ExchangeDeep Learning Toolbox についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by