[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 23:11:50 -0700 (PDT) |
yes...i believe its correct logically but then my result is wrong.
wrong in a sense that the system does not give me the values that were less
than 1.
instead, the values of the matrix displayed are of 1 and less than 1.
maybe you all can try out the my simple codes.
Hmm...maybe my implementations are wrong.
===================my codes======================
##START
##define global variables
global x_odd;
global x_even;
global y_odd;
global y_even;
##load grayscale colour map
colormap('default');
##retrieve the RGB data from JPEG file
[r,g,b]=imread('chinese1.jpg');
##changing from RGB color format to Octave image format
[x,map]= rgb2ind(r,g,b);
##to change to pixel values to 0.0 or 1.0
gray = ind2gray(x,map);
monoColor = mat2gray(gray);
##to display the black and white matrix
##imshow(monoColor);
##to retrieve matrix size
row=rows(x);
column=columns(x);
##to compute row values
if (mod(row,2) == 1)
x_odd = floor(row/8) + 1;
printf("The value of x_odd = %d\n", x_odd);
else
x_even = floor(row/8);
printf("The value of x_even = %d\n", x_even);
endif
##to compute column values
if (mod(column,2) == 1)
y_odd = floor(column/8) + 1;
printf("The value of y_odd = %d\n", y_odd);
else
y_even = floor(column/8);
printf("The value of y_even = %d\n", y_even);
endif
##imshow(monoColor);
##monoColor(1:row,:)
[i,j]=find(monoColor<1);
##to find the number of consecutive black pixels horizontally
for x = 1 : row
for y = 1 : column
## test(x,y)=floor(monoColor(x,y));
test(x,y)=monoColor(i(x),j(y));
endfor
endfor
save -text 'test.txt' test;
save -text 'chinese1.txt' monoColor;
##END
===================my codes======================
shoker
Quentin Spencer wrote:
>
> shoker_17 wrote:
>> 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! : )
>>
>
> I don't seen any reason why Paul' suggestion isn't working. I suggest
> checking the input to see if it's what you think it is.
>
> Quentin
>
> _______________________________________________
> Help-octave mailing list
> address@hidden
> https://www.cae.wisc.edu/mailman/listinfo/help-octave
>
>
http://www.nabble.com/user-files/236037/chinese1.jpg
--
View this message in context:
http://www.nabble.com/HELP-%3A%3A-if%28%29-problems-encountered-tf2278226.html#a6336987
Sent from the Octave - General forum at Nabble.com.