Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
video dimensions

Subject: video dimensions

From: Jessica

Date: 1 Mar, 2011 20:51:05

Message: 1 of 7

Hi,

Is it possible to display videos at different resolutions than they are? For example, I have a video that is 420 x 315 pixels. I would like to display it, using the below code, at 640 x 480 pixels so that I can extract pixel locations:

MovieFile = mmreader('01_3-30-10_94700_A.mov'); % Change movie file name
FirstFrame=read(MovieFile, 1); %Change frame number of interest
imshow(FirstFrame);
hold on;
axis on;
[x,y] = ginput(2);

Subject: video dimensions

From: ImageAnalyst

Date: 1 Mar, 2011 21:23:57

Message: 2 of 7

On Mar 1, 3:51 pm, "Jessica" <jyorzin...@ucdavis.edu> wrote:
> Hi,
>
> Is it possible to display videos at different resolutions than they are? For example, I have a video that is 420 x 315 pixels. I would like to display it, using the below code, at 640 x 480 pixels so that I can extract pixel locations:
>
> MovieFile = mmreader('01_3-30-10_94700_A.mov'); % Change movie file name
> FirstFrame=read(MovieFile, 1); %Change frame number of interest
> imshow(FirstFrame);
> hold on;
> axis on;
> [x,y] = ginput(2);

-----------------------------------------------------------
Yes it's possible. Normally the display will scale your image to fit
in the display window, however many pixels that may be (unless you
instruct it to do something else).

Subject: video dimensions

From: Jessica

Date: 1 Mar, 2011 21:35:15

Message: 3 of 7

ImageAnalyst <imageanalyst@mailinator.com> wrote in message <cd990480-abd9-41bf-acdf-4ea190401120@a11g2000pro.googlegroups.com>...
> On Mar 1, 3:51 pm, "Jessica" <jyorzin...@ucdavis.edu> wrote:
> > Hi,
> >
> > Is it possible to display videos at different resolutions than they are? For example, I have a video that is 420 x 315 pixels. I would like to display it, using the below code, at 640 x 480 pixels so that I can extract pixel locations:
> >
> > MovieFile = mmreader('01_3-30-10_94700_A.mov'); % Change movie file name
> > FirstFrame=read(MovieFile, 1); %Change frame number of interest
> > imshow(FirstFrame);
> > hold on;
> > axis on;
> > [x,y] = ginput(2);
>
> -----------------------------------------------------------
> Yes it's possible. Normally the display will scale your image to fit
> in the display window, however many pixels that may be (unless you
> instruct it to do something else).


And how do you instruct it to do this, in my example?

Subject: video dimensions

From: ImageAnalyst

Date: 1 Mar, 2011 21:54:09

Message: 4 of 7

On Mar 1, 4:35 pm, "Jessica" <jyorzin...@ucdavis.edu> wrote:
> ImageAnalyst <imageanal...@mailinator.com> wrote in message <cd990480-abd9-41bf-acdf-4ea190401...@a11g2000pro.googlegroups.com>...
> > On Mar 1, 3:51 pm, "Jessica" <jyorzin...@ucdavis.edu> wrote:
> > > Hi,
>
> > > Is it possible to display videos at different resolutions than they are? For example, I have a video that is 420 x 315 pixels. I would like to display it, using the below code, at 640 x 480 pixels so that I can extract pixel locations:
>
> > > MovieFile = mmreader('01_3-30-10_94700_A.mov'); % Change movie file name
> > > FirstFrame=read(MovieFile, 1); %Change frame number of interest
> > > imshow(FirstFrame);
> > > hold on;
> > > axis on;
> > > [x,y] = ginput(2);
>
> > -----------------------------------------------------------
> > Yes it's possible.  Normally the display will scale your image to fit
> > in the display window, however many pixels that may be (unless you
> > instruct it to do something else).
>
> And how do you instruct it to do this, in my example?
------------------------------------------------------------------------------------------------------------------------------
With the imshow() function, like you did. You can also make axes
beforehand, of a known size, if you want. Or you can resize any
display at any time, even after you have displayed something in it.

Subject: video dimensions

From: Jessica

Date: 3 Mar, 2011 17:57:04

Message: 5 of 7

ImageAnalyst <imageanalyst@mailinator.com> wrote in message <2ab1cd81-ce59-404a-9a96-5106455f5b0b@q12g2000prb.googlegroups.com>...
> On Mar 1, 4:35 pm, "Jessica" <jyorzin...@ucdavis.edu> wrote:
> > ImageAnalyst <imageanal...@mailinator.com> wrote in message <cd990480-abd9-41bf-acdf-4ea190401...@a11g2000pro.googlegroups.com>...
> > > On Mar 1, 3:51 pm, "Jessica" <jyorzin...@ucdavis.edu> wrote:
> > > > Hi,
> >
> > > > Is it possible to display videos at different resolutions than they are? For example, I have a video that is 420 x 315 pixels. I would like to display it, using the below code, at 640 x 480 pixels so that I can extract pixel locations:
> >
> > > > MovieFile = mmreader('01_3-30-10_94700_A.mov'); % Change movie file name
> > > > FirstFrame=read(MovieFile, 1); %Change frame number of interest
> > > > imshow(FirstFrame);
> > > > hold on;
> > > > axis on;
> > > > [x,y] = ginput(2);
> >
> > > -----------------------------------------------------------
> > > Yes it's possible.  Normally the display will scale your image to fit
> > > in the display window, however many pixels that may be (unless you
> > > instruct it to do something else).
> >
> > And how do you instruct it to do this, in my example?
> ------------------------------------------------------------------------------------------------------------------------------
> With the imshow() function, like you did. You can also make axes
> beforehand, of a known size, if you want. Or you can resize any
> display at any time, even after you have displayed something in it.


Could you provide a few lines of code that would accomplish this?
Thanks!

Subject: video dimensions

From: ImageAnalyst

Date: 3 Mar, 2011 18:30:10

Message: 6 of 7

On Mar 3, 12:57 pm, "Jessica" <jyorzin...@ucdavis.edu> wrote:
> Could you provide a few lines of code that would accomplish this?
> Thanks!
----------------------------------------------------------------
See this demo I previously posted (on January 18, 2011):
It shows you how to resize subplots, plot, images, axes, whatever you
have the handle to.


% by ImageAnalyst
% IMPORTANT: The newsreader may break long lines into multiple lines.
% Be sure to join any long lines that got split into multiple single
lines.
% These can be found by the red lines on the left side of your
% text editor, which indicate syntax errors, or else just run the
% code and it will stop at the split lines with an error.

clc; % Clear the command window.
close all; % Close all figures (except those of imtool.)
imtool close all; % Close all imtool figures.
clear; % Erase all existing variables.
workspace; % Make sure the workspace panel is showing.
fontSize = 20;

% Change the current folder to the folder of this m-file.
if(~isdeployed)
        cd(fileparts(which(mfilename)));
end

% Read in a standard MATLAB gray scale demo image.
grayImage = imread('cameraman.tif');
% Display the original gray scale image.
subplot(1, 3, 1);
imshow(grayImage, []);
title('Original Grayscale Image', 'FontSize', fontSize);
% Enlarge figure to full screen.
set(gcf, 'Position', get(0,'Screensize'));
set(gcf,'name','Demo by ImageAnalyst','numbertitle','off')

% Let's compute and display the histogram.
[pixelCount grayLevels] = imhist(grayImage);
handleToAxes = subplot(1, 3, 2);
bar(pixelCount);
title('Histogram of original image');
xlim([0 grayLevels(end)]); % Scale x axis manually.

posAxes = get(handleToAxes, 'Position')
uiwait(msgbox('Click OK to shrink the plot'));
% Find center
xCenter = posAxes(1) + 0.5 * posAxes(3)
yCenter = posAxes(2) + 0.5 * posAxes(4)
% Enlarge it
scaleFactor = 0.5;
newWidth = scaleFactor * posAxes(3)
newHeight = scaleFactor * posAxes(4)
newXLeft = xCenter - 0.5 * newWidth
newYBottom = xCenter - 0.5 * newHeight
set(handleToAxes, 'Position', [newXLeft newYBottom newWidth
newHeight]);

Subject: video dimensions

From: Jessica

Date: 3 Mar, 2011 19:08:04

Message: 7 of 7

ImageAnalyst <imageanalyst@mailinator.com> wrote in message <ec23d065-3b68-4a1e-9b10-2ab65e51fd1f@a11g2000pro.googlegroups.com>...
> On Mar 3, 12:57 pm, "Jessica" <jyorzin...@ucdavis.edu> wrote:
> > Could you provide a few lines of code that would accomplish this?
> > Thanks!
> ----------------------------------------------------------------
> See this demo I previously posted (on January 18, 2011):
> It shows you how to resize subplots, plot, images, axes, whatever you
> have the handle to.
>
>
> % by ImageAnalyst
> % IMPORTANT: The newsreader may break long lines into multiple lines.
> % Be sure to join any long lines that got split into multiple single
> lines.
> % These can be found by the red lines on the left side of your
> % text editor, which indicate syntax errors, or else just run the
> % code and it will stop at the split lines with an error.
>
> clc; % Clear the command window.
> close all; % Close all figures (except those of imtool.)
> imtool close all; % Close all imtool figures.
> clear; % Erase all existing variables.
> workspace; % Make sure the workspace panel is showing.
> fontSize = 20;
>
> % Change the current folder to the folder of this m-file.
> if(~isdeployed)
> cd(fileparts(which(mfilename)));
> end
>
> % Read in a standard MATLAB gray scale demo image.
> grayImage = imread('cameraman.tif');
> % Display the original gray scale image.
> subplot(1, 3, 1);
> imshow(grayImage, []);
> title('Original Grayscale Image', 'FontSize', fontSize);
> % Enlarge figure to full screen.
> set(gcf, 'Position', get(0,'Screensize'));
> set(gcf,'name','Demo by ImageAnalyst','numbertitle','off')
>
> % Let's compute and display the histogram.
> [pixelCount grayLevels] = imhist(grayImage);
> handleToAxes = subplot(1, 3, 2);
> bar(pixelCount);
> title('Histogram of original image');
> xlim([0 grayLevels(end)]); % Scale x axis manually.
>
> posAxes = get(handleToAxes, 'Position')
> uiwait(msgbox('Click OK to shrink the plot'));
> % Find center
> xCenter = posAxes(1) + 0.5 * posAxes(3)
> yCenter = posAxes(2) + 0.5 * posAxes(4)
> % Enlarge it
> scaleFactor = 0.5;
> newWidth = scaleFactor * posAxes(3)
> newHeight = scaleFactor * posAxes(4)
> newXLeft = xCenter - 0.5 * newWidth
> newYBottom = xCenter - 0.5 * newHeight
> set(handleToAxes, 'Position', [newXLeft newYBottom newWidth
> newHeight]);
>

I tried this code:


axis([0 640 0 480])
MovieFile = mmreader('01_3-30-10_94700.mov'); % Change movie file name
FirstFrame=read(MovieFile, 1); %Change frame number of interest
imshow(FirstFrame,'InitialMagnification', 'fit');
axis on
axis([0 640 0 480])

The axis expanded but the image remained small in the upper left corner.


I also tried:

clear all
handleToAxes = axes('position',[0 0 640 480]);
set(handleToAxes, 'Position', [0 0 640 480]);
MovieFile = mmreader('01_3-30-10_94700.mov'); % Change movie file name
FirstFrame=read(MovieFile, 1); %Change frame number of interest
imshow(FirstFrame,'InitialMagnification', 'fit');
axis on

But the image doesn't even appear.
Thanks!

Tags for this Thread

No tags are associated with this thread.

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us