imdivide
Divide one image into another or divide image by constant
Syntax
Description
Examples
Divide Two uint8 Arrays
This example shows how to divide twouint8
arrays.
X = uint8([ 255 0 75; 44 225 100]); Y = uint8([ 50 50 50; 50 50 50 ]);
Divide each element inX
by the corresponding element inY
. Note that fractional values greater than or equal to 0.5 are rounded up to the nearest integer.
Z = imdivide(X,Y)
Z =2x3 uint8 matrix5 0 2 1 5 2
Divide each element inY
by the corresponding element inX
. Note that when dividing by zero, the output is truncated to the range of the integer type.
W = imdivide(Y,X)
W =2x3 uint8 matrix0 255 1 1 0 1
Divide Image Background
Read a grayscale image into the workspace.
I = imread('rice.png');
估计背景。
background = imopen(I,strel('disk',15));
Divide out the background from the image.
J = imdivide(I,background);
Display the original image and the processed image.
imshow(I)
figure imshow(J,[])
Divide an Image by a Constant Factor
Read an image into the workspace.
I = imread('rice.png');
Divide each value of the image by a constant factor of 2.
J = imdivide(I,2);
Display the original image and the processed image.
imshow(I)
figure imshow(J)
Input Arguments
X
—First array
numeric array|逻辑阵列
First array, specified as a numeric array or logical array of any dimension.
Y
—Second array
numeric scalar|numeric array|逻辑阵列
Second array (divisor) to be divided fromX
, specified as a numeric or logical array of the same size and class asX
, or a numeric scalar of typedouble
.
Output Arguments
Z
— Quotient
numeric array
Quotient, returned as a numeric array of the same size asX
.Z
is the same class asX
unlessX
is logical, in which caseZ
is data typedouble
. IfX
is an integer array, elements of the output that exceed the range of the integer type are truncated, and fractional values are rounded.
Version History
See Also
imabsdiff
|imadd
|imcomplement
|imlincomb
|immultiply
|imsubtract
Abrir ejemplo
Tiene una versión modificada de este ejemplo. ¿Desea abrir este ejemplo con sus modificaciones?
Comando de MATLAB
Ha hecho clic en un enlace que corresponde a este comando de MATLAB:
Ejecute el comando introduciéndolo en la ventana de comandos de MATLAB. Los navegadores web no admiten comandos de MATLAB.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select:.
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina(Español)
- Canada(English)
- United States(English)
Europe
- 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
- United Kingdom(English)