how to use imresize function. (2024)

3visualizaciones (últimos 30días)

Mostrar comentarios más antiguos

mohd akmal masud el 2 de Ag. de 2023

  • Enlazar

    Enlace directo a esta pregunta

    https://la.mathworks.com/matlabcentral/answers/2003492-how-to-use-imresize-function

  • Enlazar

    Enlace directo a esta pregunta

    https://la.mathworks.com/matlabcentral/answers/2003492-how-to-use-imresize-function

Comentada: mohd akmal masud el 30 de Ag. de 2023

Respuesta aceptada: Shubham

  • image2988.zip
  • unknown.zip

Abrir en MATLAB Online

Dear All,

I have image unknown.png, I want to covert the size and map same with the image image2988.png (28x28 uint8)

Because my unknown.png is 2320x2864x3 uint8

I tried this command

%testing

testing = imread('unknown.png');

testing1 = imresize(testing, [28 28])

but the image still have 28x28x3 uint8 . What I want is just 28x28 uint8 only. Why the number of 3 have

3 comentarios

Mostrar 1 comentario más antiguoOcultar 1 comentario más antiguo

Stephen23 el 2 de Ag. de 2023

Enlace directo a este comentario

https://la.mathworks.com/matlabcentral/answers/2003492-how-to-use-imresize-function#comment_2835862

  • Enlazar

    Enlace directo a este comentario

    https://la.mathworks.com/matlabcentral/answers/2003492-how-to-use-imresize-function#comment_2835862

Editada: Stephen23 el 2 de Ag. de 2023

"Why the number of 3 have"

IMRESIZE does not convert an RGB image into a grayscale or select color channels or whatever unspecified operation you expect to occur. IMRESIZE uses a fairly universal definition of "resizing" an image: it changes the number of row/columns an image has, exactly as its documentation clearly states "If A has more than two dimensions, then imresize only resizes the first two dimensions". It is highly recommended to read the documentation for functions that you are using, to learn what those functions do and how to call them properly. Reading the documentation is faster and more reliable than guessing.

If you want one channel of your image then use indexing.

If you want to convert an RGB (e.g. truecolor) image to grayscale then use IM2GRAY:

https://www.mathworks.com/help/matlab/ref/im2gray.html

mohd akmal masud el 2 de Ag. de 2023

Enlace directo a este comentario

https://la.mathworks.com/matlabcentral/answers/2003492-how-to-use-imresize-function#comment_2835882

  • Enlazar

    Enlace directo a este comentario

    https://la.mathworks.com/matlabcentral/answers/2003492-how-to-use-imresize-function#comment_2835882

Thats means the number of 3 showing the image is RGB.

Stephen23 el 2 de Ag. de 2023

Enlace directo a este comentario

https://la.mathworks.com/matlabcentral/answers/2003492-how-to-use-imresize-function#comment_2835952

  • Enlazar

    Enlace directo a este comentario

    https://la.mathworks.com/matlabcentral/answers/2003492-how-to-use-imresize-function#comment_2835952

Editada: Stephen23 el 2 de Ag. de 2023

"Thats means the number of 3 showing the image is RGB."

Probably, but not necessarily: it might be an Lab image, or use any of countless other colorspaces.

The number of channnels does not uniquely determine what colorspace an image is encoded with, that can only be determined with prior-knowledge (e.g. the color encoding stored as part of in an image file).

Iniciar sesión para comentar.

Iniciar sesión para responder a esta pregunta.

Respuesta aceptada

Shubham el 2 de Ag. de 2023

  • Enlazar

    Enlace directo a esta respuesta

    https://la.mathworks.com/matlabcentral/answers/2003492-how-to-use-imresize-function#answer_1282162

  • Enlazar

    Enlace directo a esta respuesta

    https://la.mathworks.com/matlabcentral/answers/2003492-how-to-use-imresize-function#answer_1282162

Hi Mohd,

The value "3" in the statement "2320x2864x3 uint8" refers to the number of color channels in the image. In this case, the image has 3 color channels, namely Red, Green, and Blue (RGB). Each pixel in the image is represented by three 8-bit unsigned integers (uint8) for the intensity values of each color channel.

If you want to convert the resulting image to grayscale and have a size of "28x28 uint8" with a single channel, you can use the "rgb2gray" function in MATLAB. Details

Also refer to this MATLAB Answer for more insight.

0 comentarios

Mostrar -2 comentarios más antiguosOcultar -2 comentarios más antiguos

Iniciar sesión para comentar.

Más respuestas (1)

Image Analyst el 2 de Ag. de 2023

  • Enlazar

    Enlace directo a esta respuesta

    https://la.mathworks.com/matlabcentral/answers/2003492-how-to-use-imresize-function#answer_1282367

  • Enlazar

    Enlace directo a esta respuesta

    https://la.mathworks.com/matlabcentral/answers/2003492-how-to-use-imresize-function#answer_1282367

Abrir en MATLAB Online

"I have image unknown.png, I want to covert the size and map same with the image image2988.png (28x28 uint8)" so I take it that the unknown.png is an RGB image and image2988.png is an indexed image and you want to convert the unknown image to an indexed image, using the same colormap as image2988, and then resize it. So you can do this (untested)

% Read in reference image and it's colormap

[indexedImage, cmap] = imread('image2988.png');

% Get it's size.

[rows, columns, numberOfColorChannels] = size(indexedImage)

if isempty(cmap)

% If colormap does not exist, use gray scale.

cmap = gray(256);

end

% Read in unknown RGB image

unknownImage = imread('unknown.png');

% Resize image. Note this may change colors obviously.

unknownImage = imresize(unknownImage, [rows, columns]); % It's still an RGB image after this.

% Turn into an indexed image using the same colormap as the reference image.

unknownImage = rgb2ind(unknownImage, cmap);

If it doesn't work then let me know and I'll download your zip files and try it and correct it. Or if I didn't understand what you meant when you said you wanted to apply the map of image2988 to unknown, then please explain better.

1 comentario

Mostrar -1 comentarios más antiguosOcultar -1 comentarios más antiguos

mohd akmal masud el 30 de Ag. de 2023

Enlace directo a este comentario

https://la.mathworks.com/matlabcentral/answers/2003492-how-to-use-imresize-function#comment_2867181

  • Enlazar

    Enlace directo a este comentario

    https://la.mathworks.com/matlabcentral/answers/2003492-how-to-use-imresize-function#comment_2867181

THANK YOU @Stephen23 @Image Analyst @Shubham

Iniciar sesión para comentar.

Iniciar sesión para responder a esta pregunta.

Ver también

Categorías

MATLABGraphicsImages

Más información sobre Images en Help Center y File Exchange.

Etiquetas

  • image acquisition
  • image segmentation
  • digital image processing
  • image analysis
  • image processing

Productos

  • Image Processing Toolbox

Versión

R2023a

Community Treasure Hunt

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

Start Hunting!

Se ha producido un error

No se puede completar la acción debido a los cambios realizados en la página. Vuelva a cargar la página para ver el estado actualizado.


Translated by how to use imresize function. (8)

how to use imresize function. (9)

Seleccione un país/idioma

Seleccione un país/idioma para obtener contenido traducido, si está disponible, y ver eventos y ofertas de productos y servicios locales. Según su ubicación geográfica, recomendamos que seleccione: .

También puede seleccionar uno de estos países/idiomas:

América

  • América Latina (Español)
  • Canada (English)
  • United States (English)

Europa

  • Belgium (English)
  • Denmark (English)
  • Deutschland (Deutsch)
  • España (Español)
  • Finland (English)
  • France (Français)
  • Ireland (English)
  • Italia (Italiano)
  • Luxembourg (English)
  • Netherlands (English)
  • Norway (English)
  • Österreich (Deutsch)
  • Portugal (English)
  • Sweden (English)
  • Switzerland
    • Deutsch
    • English
    • Français
  • United Kingdom(English)

Asia-Pacífico

  • Australia (English)
  • India (English)
  • New Zealand (English)
  • 中国
  • 日本Japanese (日本語)
  • 한국Korean (한국어)

Comuníquese con su oficina local

how to use imresize function. (2024)

References

Top Articles
Latest Posts
Recommended Articles
Article information

Author: Greg O'Connell

Last Updated:

Views: 6577

Rating: 4.1 / 5 (42 voted)

Reviews: 81% of readers found this page helpful

Author information

Name: Greg O'Connell

Birthday: 1992-01-10

Address: Suite 517 2436 Jefferey Pass, Shanitaside, UT 27519

Phone: +2614651609714

Job: Education Developer

Hobby: Cooking, Gambling, Pottery, Shooting, Baseball, Singing, Snowboarding

Introduction: My name is Greg O'Connell, I am a delightful, colorful, talented, kind, lively, modern, tender person who loves writing and wants to share my knowledge and understanding with you.