help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

## Re: HELP :: if() problems encountered

 From: Paul Roberts Subject: Re: HELP :: if() problems encountered Date: Fri, 15 Sep 2006 09:00:52 -0700

```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

```
```
```

reply via email to

 [Prev in Thread] Current Thread [Next in Thread]