double,unit8

  • Follow


greetings to all
what is the difference "double(imread('image.bmp'))" with "unit8('image.bmp')"
namely for what we use "double" and "unit8".
are they relevant to dimensions of matrices

thanks in advance
0
Reply mrt 11/25/2010 9:15:06 AM

"mrt " <muratyesilyurt@hotmail.com> wrote in message <icl9eq$lni$1@fred.mathworks.com>...
> greetings to all
> what is the difference "double(imread('image.bmp'))" with "unit8('image.bmp')"
> namely for what we use "double" and "unit8".
> are they relevant to dimensions of matrices
> 
> thanks in advance

i have got one frame from mpeg video
 i m doing "double" this frame . but then i cant do rgb2 yuv this frame
i dont understand why error do
0
Reply mrt 11/25/2010 10:59:07 AM


Dear mrt,

> what is the difference "double(imread('image.bmp'))" with "unit8('image.bmp')"

1. double(imread('image.bmp'))
This reads the image file "image.bmp" into an Matlab array and converts the type of the array to DOUBLE.

2. uint8('image.bmp')
This converts the string 'image.bmp' to a UINT8 vector. Strings are using Unicode characters in Matlab, such that they are equivalent to UINT16 vectors. Limiting the values to the range of UINT8 does not change anything, if the characters are in the range of ASCII values.

Both commands do absolutely different things. I assume, you forgot an "imread" in the second command.

Kind regards, Jan
0
Reply Jan 11/25/2010 2:24:04 PM

"Jan Simon" <matlab.THIS_YEAR@nMINUSsimon.de> wrote in message <iclri4$62u$1@fred.mathworks.com>...
> Dear mrt,
> 
> > what is the difference "double(imread('image.bmp'))" with "unit8('image.bmp')"
> 
> 1. double(imread('image.bmp'))
> This reads the image file "image.bmp" into an Matlab array and converts the type of the array to DOUBLE.
> 
> 2. uint8('image.bmp')
> This converts the string 'image.bmp' to a UINT8 vector. Strings are using Unicode characters in Matlab, such that they are equivalent to UINT16 vectors. Limiting the values to the range of UINT8 does not change anything, if the characters are in the range of ASCII values.
> 
> Both commands do absolutely different things. I assume, you forgot an "imread" in the second command.
> 
> Kind regards, Jan


thanks for reply Jan
basic problem is below "double". BECAUSE I GET THE ERROR "matrices dimension error 
G = cover_object(:,:,2); "

DOUBLE is how many dimensional matrix ???? BECAUSE RGB 3 DIMENSONAL MATRIX
I DONT KNOW WHAT I EXPLAIN 
cover_object=double('resim.bmp'); 
        % RGB ->YUV 
        R = cover_object(:,:,1); 
        G = cover_object(:,:,2); 
        B = cover_object(:,:,3); 
        Y=zeros(size(R)); 
        U=zeros(size(G)); 
        V=zeros(size(B)); 
        [row,col]=size(R); 
       
        % RGB-->YUV»» 
        for j=1:row 
            for k=1:col 
                Y(j,k)=0.257*R(j,k)+0.504*G(j,k)+0.098*B(j,k)+16; 
         %       U(j,k)=-0.148*R(j,k)-0.291*G(j,k)+0.439*B(j,k)+128; 
         %       V(j,k)=0.439*R(j,k)-0.368*G(j,k)-0.071*B(j,k)+128; 
            end 
        end 
0
Reply mrt 11/25/2010 3:27:04 PM

On 25/11/10 9:27 AM, mrt wrote:

> basic problem is below "double". BECAUSE I GET THE ERROR "matrices
> dimension error G = cover_object(:,:,2); "
>
> DOUBLE is how many dimensional matrix ???? BECAUSE RGB 3 DIMENSONAL MATRIX
> I DONT KNOW WHAT I EXPLAIN cover_object=double('resim.bmp'); % RGB ->YUV

No! As Jan explained, that converts the *string* 'resim.bmp' to double 
precision numbers, and does not read the *file* named 'resim.bmp' . A 
string is a character array that is 1 by (number of characters) with all 
remaining dimensions being of length 1. When you attempt to access the 
second pane of the converted string, you get an error because that 
second pane does not exist.

When you have an object that is fundamentally numeric (as strings are 
internally), then double() returns an array of exactly the same size as 
the original object.

Your problem is that you need to read in the file, not just process the 
string that is the *name* of the file. Your previous question already 
had code for that, imread('resim.bmp')
0
Reply Walter 11/25/2010 3:35:57 PM

Dae mrt,

> > I DONT KNOW WHAT I EXPLAIN

I think, this is the main problem.

> Walter wrote:
> Your problem is that you need to read in the file, not just process the 
> string that is the *name* of the file. 

I assume the problem is, that you need to read the "Getting Started" section of the documentation. Your problems are very fundamental and going line by line through the section thought to support beginners is very recommended. Matlab's complexity is connected to its great power. In consequence learning Matlab is a hard task.

Welcome at Matlab, Jan
0
Reply Jan 11/25/2010 4:19:04 PM

mrt:
Once you figure out how to use imread(), I'm wondering if you really
need YUV or if you can just use rgb2hsv(), rgb2ntsc(), rgb2ycbcr(), or
rgb2lab() or any of the other similar color space conversions.  Does
it HAVE to be YUV?  What are you trying to do?  Color segmentation
(like in my demos http://www.mathworks.com/matlabcentral/fileexchange/authors/31862)
or something else???

imdouble basically converts the image to double and scales it in
between 0 and 1.  Just using double() converts your image to double
but does not normalize to [0,1] which many image processing functions
want for inputs.

Finally you might also review some of our old discussions on double
and color space conversions:
http://www.mathworks.com/matlabcentral/newsreader/search_results?search_string=im2double+imageanalyst
ImageAnalyst
0
Reply ImageAnalyst 11/25/2010 5:31:02 PM

ImageAnalyst <imageanalyst@mailinator.com> wrote in message <fb2eae1d-ef0b-478f-845b-9e8e80f337d9@d8g2000yqf.googlegroups.com>...
> mrt:
> Once you figure out how to use imread(), I'm wondering if you really
> need YUV or if you can just use rgb2hsv(), rgb2ntsc(), rgb2ycbcr(), or
> rgb2lab() or any of the other similar color space conversions.  Does
> it HAVE to be YUV?  What are you trying to do?  Color segmentation
> (like in my demos http://www.mathworks.com/matlabcentral/fileexchange/authors/31862)
> or something else???
> 
> imdouble basically converts the image to double and scales it in
> between 0 and 1.  Just using double() converts your image to double
> but does not normalize to [0,1] which many image processing functions
> want for inputs.
> 
> Finally you might also review some of our old discussions on double
> and color space conversions:
> http://www.mathworks.com/matlabcentral/newsreader/search_results?search_string=im2double+imageanalyst
> ImageAnalyst

THANKS  ALL YOU FOR REPLY
I'M SORRY ALL YOU
I COULD NOT TELL.BECAUSE I DIDN'T SEND FULL CODE.SO YOU DONT UNDERSTAND.

clc,clear all,close all; 
start_time=cputime; 
 
watermark_image=double(imread('lena.bmp')); 
[m n]=size(watermark_image); 
 
watermark_image_size=reshape(gomu_resim,m*n,1); 
gomu_resim_boyut=size(watermark_image_size,1); 
 
mov = aviread('hall.avi'); 
 
aviobj = avifile('try.avi','compression','None'); 
aviobj.Fps = 25; 
 
for i=1:30
  
        film=mov(i); 
        cover_object=double(film.cdata); 
        % RGB ->YUV 
        R = cover_object(:,:,1); 
        G = cover_object(:,:,2); %ERROR  LINE !!!!!!!
        B = cover_object(:,:,3); 
        Y=zeros(size(R)); 
        U=zeros(size(G)); 
        V=zeros(size(B)); 
        [row,col]=size(R); 
       
        % RGB-->YUV»» 
        for j=1:row 
            for k=1:col 
                Y(j,k)=0.257*R(j,k)+0.504*G(j,k)+0.098*B(j,k)+16; 
         %       U(j,k)=-0.148*R(j,k)-0.291*G(j,k)+0.439*B(j,k)+128; 
         %       V(j,k)=0.439*R(j,k)-0.368*G(j,k)-0.071*B(j,k)+128; 
            end 
        end 
 
0
Reply mrt 11/26/2010 8:22:05 AM

On 26/11/10 2:22 AM, mrt wrote:

> mov = aviread('hall.avi');

> for i=1:30
>
> film=mov(i); cover_object=double(film.cdata);

What reason do you have to expect that the avi file will always contain 
RGB ("true-color") images, and never contain indexed ("pseudo-color") 
images? You are not checking result of the aviinfo() call you make that 
could tell you this, and you are not checking for the case where 
film.map is non-empty indicating a pseudo-color frame.
0
Reply Walter 11/26/2010 9:43:14 AM

8 Replies
560 Views

(page loaded in 0.084 seconds)

Similiar Articles:













7/24/2012 5:02:32 AM


Reply: