Image processing for a set of images but showing "Array indices must be positive integers or logical values" for another set of images?

조회 수: 2 (최근 30일)
I made an image processing script which can work for a set of images, but when I try to process another set of images with the same script, it shows errors saying "Array indices must be positive integers or logical values".
Could anyone help me with this please?
Array indices must be positive integers or logical values.
Error in training (line 16)
mean5=mean(double(A3(:)<1500))
This is my code:
%read images
A=imread('r30jun97.giant.04--1---2.tif');
%increase intensity
A1 = A*1000;
%mask
mask = A1>=2000;
A2 = uint16(mask).*A1;
%median filter to remove noise
meanFilter = ones(3)/9;
A3 = imfilter(A2,meanFilter);
%statistics
mean5=mean(double(A3(:)<1500));
sd5=sqrt(var(double(A3(:)<1500)));

채택된 답변

Walter Roberson
Walter Roberson 2019년 11월 24일
Guessing
mask = A3<1500;
mean5 = mean(A3(mask));
sd5 = std(A3(mask)) ;
However you should check whether you accidentally created a variable named mean
  댓글 수: 4
Yuhong Jin
Yuhong Jin 2019년 11월 25일
My intention is to calculate the mean and standard deviation in a specified range of A3. Should I define another variable or I can do it with mean?
Walter Roberson
Walter Roberson 2019년 11월 25일
In that case the code I posted above would work. Or you might prefer to write it as
A3_5 = A3(A3<1500);
mean5 = mean(A3_5);
sd5 = std(A3_5);

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Computer Vision with Simulink에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by