[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: HELP :: if() problems encountered
From: |
shoker_17 |
Subject: |
Re: HELP :: if() problems encountered |
Date: |
Fri, 15 Sep 2006 10:13:44 -0700 (PDT) |
Hmm...actually, i believe that my for loop and if statement are correctly
logically but it seems that i have problem retrieving those values less than
1 from the matrix. This seems to me that either i use the "if()" wrongly or
the system cannot recognise the "<1" condition.
paul,
your statement cant seem to work. instead of those values less than zero, it
only manage to find the following output but thanks anyway! : )
=======================output from paul's suggestion=====================
2 1
4 1
6 1
8 1
10 1
11 1
12 1
13 1
14 1
16 1
18 1
20 1
22 1
24 1
26 1
28 1
30 1
32 1
2 2
4 2
6 2
8 2
10 2
12 2
14 2
15 2
16 2
18 2
=======================output from paul's suggestion=====================
shoker
Paul Roberts wrote:
>
> If you want the row and column indicies for each non-zero element,
> rather than setting them to zero, you could use:
>
> [i,j] = find(monoColor < 1);
>
> i will hold the row indicies for each element, and j will hold the
> column indicies. So, the first element with intensity less than 1 is:
>
> monoColor(i(1),j(1))
>
> Paul
>
> On 9/15/06, Quentin Spencer <address@hidden> wrote:
>> shoker_17 wrote:
>> > Status : Beginner
>> >
>> > Version : Octave 2.1.72
>> > Purpose : image Processing
>> > Problem : If () statement
>> > Descriptions : I was trying to manipulate a matrix in image
>> intensity. The
>> > main idea was to retrieve those data that were less than 1 from
>> monoColor.
>> >
>> > ##to find the number of consecutive black pixels horizontally
>> > ##monoColor : image intensity of 32 rows and columns
>> > for x = 1 : row
>> > for y = 1 : column
>> > if(monoColor(x,y) < 1) //tryin to find
>> values in monoColor
>> > less than 1
>> > test(x,y)= monoColor(x, y);
>> > endif
>> > endfor
>> > endfor
>> >
>> > In the above code, i was trying to find the values in the matrix which
>> are
>> > less than 1.
>> > However, to my dismay, I did not manage to get results i wanted.
>> Instead, i
>> > obtained the same number of rows and columns. Besides thism the values
>> > smaller than 1 and 1 were also obtained.
>> >
>> > Maybe i used the syntax wrongly else "<1" doesnt seems to work at all.
>> > *weird*
>> >
>> > =============some monoColor image intensity==================
>> >
>> > 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
>> > 1 1 1 1 0.992156862745098 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
>> > 0.996078431372549 1 0.988235294117647 1 0.996078431372549
>> 0.996078431372549
>> > 1
>> > 0.988235294117647 1 1 1 1 1 0.988235294117647 1 1 1 1 1 1 1 1 1 1 1 1
>> 1 1 1
>> > 1 1 0.996078431372549 1 0.992156862745098 1 0.988235294117647 1
>> > 0.996078431372549 0.996078431372549
>> >
>> > =============some monoColor image intensity==================
>> >
>> > =============corresponding values in test array=================
>> >
>> > 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
>> > 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
>> > 0 0 0 0 0.992156862745098 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
>> > 0.996078431372549 0 0.988235294117647 0 0.996078431372549
>> 0.996078431372549
>> > 0
>> > 0.988235294117647 1 1 1 1 1 0.988235294117647 1 1 1 1 1 1 1 1 1 1 1 1
>> 1 1 1
>> > 1 1 0.996078431372549 1 0.992156862745098 1 0.988235294117647 1
>> > 0.996078431372549 0.996078431372549
>> >
>> > =============corresponding values in test array=================
>> >
>> > H E L P !!
>> >
>>
>> It looks like what you're trying to do is set all the values that are
>> ==1 to zero. Is that right? See if the following give you the results
>> you were expecting:
>>
>> test = monoColor;
>> test(test==1) = 0;
>>
>>
>> Quentin
>>
>> _______________________________________________
>> Help-octave mailing list
>> address@hidden
>> https://www.cae.wisc.edu/mailman/listinfo/help-octave
>>
> _______________________________________________
> Help-octave mailing list
> address@hidden
> https://www.cae.wisc.edu/mailman/listinfo/help-octave
>
>
--
View this message in context:
http://www.nabble.com/HELP-%3A%3A-if%28%29-problems-encountered-tf2278226.html#a6329534
Sent from the Octave - General forum at Nabble.com.