필터 지우기
필터 지우기

In this code i used boolean true and false ,but it's not working. What can i use insted of boolean true and false?

조회 수: 1 (최근 30일)
f=imread('image1.jpg');
T = f;
T(T>60) = 255;
imshow(T)
imwrite(T,'C:\Users\VAIO\Documents\MATLAB\iso_image.jpg','jpg');
for i=1:1:M
{
start = false;
for j=1:1:N
{
if ((T<60) && (start=false))
{
temp1=j;
start=true;
}
if((T<60)&&(start=true))
temp2=j;
}
dis[i]=temp2-temp1;
}

답변 (2개)

Thorsten
Thorsten 2013년 6월 26일
The code in the if-clause is probably wrong. First, you probably want to compare a particular element of T, i.e., T(i,j) against 60. Second, use == to check equality:
if T(i,j) < 60 && start == false
Note that you don't need the extra parentheses in Matlab but you can use them if you consider it to be more readable:
if (T(i,j) < 60) && (start == false)
Same for the other if-clause.
  댓글 수: 3
Lokesh Ravindranathan
Lokesh Ravindranathan 2013년 6월 26일
Could you provide the updated code? Its possible that you are using = operator instead of == operator.
Umme Tania
Umme Tania 2013년 6월 26일
편집: Walter Roberson 2013년 6월 26일
f=imread('image1.jpg');
T = f;
T(T>60) = 255;
imshow(T)
imwrite(T,'C:\Users\VAIO\Documents\MATLAB\iso_image.jpg','jpg');
for i=1:1:M
{
start = false;
for j=1:1:N
{
if T(i,j)<60 && start==false
{
temp1=j;
start=true;
}
if T(i,j)<60 && start==true
temp2=j;
}
dis[i]=temp2-temp1;
}

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


Walter Roberson
Walter Roberson 2013년 6월 26일
MATLAB does not use {} to mark blocks. MATLAB uses {} to create cells. MATLAB uses "end" to mark the end of blocks.
For example instead of
for i=1:M { code }
MATLAB uses
for i=1:M; code; end

카테고리

Help CenterFile Exchange에서 Scalar Volume Data에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by