image reading and writing

Hi
I have been developing an algorithm which reads and imports 2 different images (.jpg files) and undertakes calculations to output and write a third different image file.
At first when reading in the images I just used double() and then I started to using rgb2gray and finally it seemed to work when using im2double instead of just double.
Why do I need to use this code:
object = mmreader('train.mpg')
frame1=read(object,1)
frame1=rgb2gray(thisframe)
frame1=im2double(thisframe)
Is this even correct what I have finally used?? Please help!

1 Commento

Image Analyst
Image Analyst il 9 Ago 2011
Actually it worked after your call to read. Anything you do after that is just part of your algorithm, like throwing away the color info or changing from integer to floating point or whatever you do after that. Anyway, why not use VideoReader, which is the more modern way of reading videos?

Accedi per commentare.

Risposte (1)

Walter Roberson
Walter Roberson il 8 Ago 2011
You define "frame1" three times, but you twice use "thisframe" without ever defining it.
object = mmreader('train.mpg');
frame1 = read(object,1);
thisframe = rgb2gray(imdouble(frame1));

5 Commenti

James
James il 9 Ago 2011
sorry i meant
object = mmreader('train.mpg')
frame1=read(object,1)
frame1=rgb2gray(frame1)
frame1=im2double(frame1)
Walter Roberson
Walter Roberson il 9 Ago 2011
http://www.mathworks.com/help/toolbox/images/ref/im2double.html
I2 = im2double(I) converts the intensity image I to double precision, rescaling the data if necessary.
http://www.mathworks.com/help/techdoc/ref/image.html
Now carefully study the table in the "Tips" section, looking at the data ranges that are valid for each type.
James
James il 10 Ago 2011
why not double() instead of im2double()??
Well this might not be a great addition but you can avoid the third step.
object= mmreader('train.mpg'); %If you have R2011a then you can replace mmreader with VideoReader
frame1= rgb2gray(read(object,1));
thisFrame = im2double(frame1);
Walter Roberson
Walter Roberson il 10 Ago 2011
James, in the table of the Tips section I referred to, what is the valid data range for RGB data represented as double precision values?

Accedi per commentare.

Richiesto:

il 8 Ago 2011

Community Treasure Hunt

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

Start Hunting!

Translated by