RunMat
  • Pricing
RunMat
GitHub
GitHub
Sign inTry in browser
DesktopRuntimePhysicsCADAdministrationAgent

Get RunMat updates

New releases, guides and examples.

Product+
  • Runtime
  • GPU
  • Parallel
  • Compile
  • Interop and MEX
  • Simulation
  • MCAD
  • ECAD
  • Enterprise
  • AI integrations
  • Pricing
  • Download
Math+
  • Signal processing
  • Linear algebra
  • Statistics
  • Curve fitting
  • Differential equations
  • Control systems
  • Optimization
  • Finance
  • Data and tables
  • Plotting
Physics+
  • Simulation overview
  • Structural
  • Thermal
  • Electromagnetic
  • Joule heating
  • Thermal stress
  • Acoustics
  • Fluid flow
  • Conjugate heat transfer
  • Fluid–structure
  • What is FEA
Industries+
  • Aerospace
  • Automotive and transportation
  • Defense
  • Electronics and semiconductors
  • Energy
  • Industrial machinery
  • Life sciences
  • Quantitative finance
Learn+
  • Guides
  • Docs
  • Function reference
  • Language reference
  • Migration guide
  • Changelog
  • MATLAB Online
  • MATLAB AI agent
  • For students
Compare+
  • RunMat vs MATLAB
  • RunMat vs Ansys
  • RunMat vs SOLIDWORKS
  • RunMat vs Altium
  • RunMat vs Cadence
  • RunMat vs COMSOL
  • RunMat vs Python
  • RunMat vs Julia
  • RunMat vs Physics AI
  • RunMat vs Octave
  • Benchmarks
  • MATLAB alternatives
  • All comparisons
Company+
  • About
  • Blog
  • Contact
  • Source code↗
  • License
  • Privacy
  • Terms

Product

  • Runtime
  • GPU
  • Parallel
  • Compile
  • Interop and MEX
  • Simulation
  • MCAD
  • ECAD
  • Enterprise
  • AI integrations
  • Pricing
  • Download

Math

  • Signal processing
  • Linear algebra
  • Statistics
  • Curve fitting
  • Differential equations
  • Control systems
  • Optimization
  • Finance
  • Data and tables
  • Plotting

Physics

  • Simulation overview
  • Structural
  • Thermal
  • Electromagnetic
  • Joule heating
  • Thermal stress
  • Acoustics
  • Fluid flow
  • Conjugate heat transfer
  • Fluid–structure
  • What is FEA

Industries

  • Aerospace
  • Automotive and transportation
  • Defense
  • Electronics and semiconductors
  • Energy
  • Industrial machinery
  • Life sciences
  • Quantitative finance

Learn

  • Guides
  • Docs
  • Function reference
  • Language reference
  • Migration guide
  • Changelog
  • MATLAB Online
  • MATLAB AI agent
  • For students

Compare

  • RunMat vs MATLAB
  • RunMat vs Ansys
  • RunMat vs SOLIDWORKS
  • RunMat vs Altium
  • RunMat vs Cadence
  • RunMat vs COMSOL
  • RunMat vs Python
  • RunMat vs Julia
  • RunMat vs Physics AI
  • RunMat vs Octave
  • Benchmarks
  • MATLAB alternatives
  • All comparisons

Company

  • About
  • Blog
  • Contact
  • Source code↗
  • License
  • Privacy
  • Terms
GitHubXLinkedIn

© Dystr, Inc. · RunMat v0.7.1, Nov 17, 2026

RunMat® is a registered trademark of Dystr, Inc. MATLAB® is a registered trademark of The MathWorks, Inc. RunMat is not affiliated with, endorsed by, or sponsored by The MathWorks, Inc.

/
See all docs
Builtin Reference
    • filter2
    • fspecial
    • imfilter

imfilter — Apply linear filtering to an image with selectable padding and output shape.

imfilter(A,H,options...) filters real numeric or logical image data with a real double scalar, vector, or matrix kernel. Images may have trailing channel or higher dimensions, while public H remains at most two-dimensional.

Syntax

B = imfilter(A, H)
B = imfilter(A, H, options...)

Inputs

A
Type
Any
Required
Yes
Description
Input image/array.
H
Type
Any
Required
Yes
Description
Filter kernel.
options
Type
Any
Required
Variadic
Description
Optional mode/shape/padding flags and fill values (e.g. 'same', 'full', 'valid', 'replicate', 'symmetric', 'circular', 'fill', padval, 'conv', 'corr').
NameTypeRequiredDefaultDescription
AAnyYes—Input image/array.
HAnyYes—Filter kernel.
optionsAnyVariadic—Optional mode/shape/padding flags and fill values (e.g. 'same', 'full', 'valid', 'replicate', 'symmetric', 'circular', 'fill', padval, 'conv', 'corr').

Returns

B
Type
NumericArray
Description
Filtered image output.
NameTypeDescription
BNumericArrayFiltered image output.

Errors

RunMat:imfilter:InvalidInput
When
Input/kernel tensors are invalid or cannot be converted.
Message
imfilter: invalid input
RunMat:imfilter:InvalidOption
When
One or more option flags or option values are invalid.
Message
imfilter: invalid option
RunMat:imfilter:Internal
When
Internal filtering operation fails.
Message
imfilter: internal operation failed
IdentifierWhenMessage
RunMat:imfilter:InvalidInputInput/kernel tensors are invalid or cannot be converted.imfilter: invalid input
RunMat:imfilter:InvalidOptionOne or more option flags or option values are invalid.imfilter: invalid option
RunMat:imfilter:InternalInternal filtering operation fails.imfilter: internal operation failed

Mode, padding, and shape

Correlation (corr) with zero padding and same-size output is the default. conv reverses the kernel along its axes. replicate, symmetric, and circular select border behavior; a real numeric scalar supplies constant padding, and RunMat-gated fill optionally consumes a following numeric scalar (otherwise zero). A numeric padding value can appear before or after fill.

same preserves image shape, full includes every overlap, and RunMat-gated valid keeps complete overlaps (possibly yielding a zero-length axis). Options are processed left to right. H is not normalized automatically; fspecial or explicit scaling can construct normalized smoothing kernels.

The image may have multiple channels or higher dimensions. H must be nonempty real double scalar, vector, or matrix; filtering extends it with singleton trailing axes. Unsupported 64-bit integer image classes and complex/sparse inputs have stable input errors.

Class and residency

Real single/double images preserve their class. Logical images round/clamp back to logical output. Documented int8/int16/int32/uint8/uint16/uint32 images round to nearest and saturate into the original class. Host and automatic-placement fallback accumulate in double; explicit resident uint32 uses double and other documented explicit resident integers use single accumulation.

A supported floating provider imfilter hook may return a new resident output. Integer and logical resident inputs use checked owner-aware host reference computation and explicit-input restoration. A typed unsupported provider operation may take the host fallback; operational upload or execution failures retain their cause and are not silently replayed. imfilter is a standalone fusion boundary.

Examples

Smooth with zero padding

I = [1 2;3 4]; H = ones(3)/9; J = imfilter(I,H); size(J)

Expected output:

ans = [2 2]

Replicate the image border

I = magic(3); H = ones(3); J = imfilter(I,H,'replicate'); size(J)

Expected output:

ans = [3 3]

Keep every kernel overlap

I = [1 2;3 4]; H = [1 2;3 4]; J = imfilter(I,H,'full'); size(J)

Expected output:

ans = [3 3]

Reverse the kernel

I = reshape(1:6,[3 2]); H = [1 2;3 4]; J = imfilter(I,H,'conv'); size(J)

Expected output:

ans = [3 2]

Wrap image borders

I = [1 2;3 4]; H = [0 1;1 0]; J = imfilter(I,H,'circular'); size(J)

Expected output:

ans = [2 2]

Complete overlaps only

I = ones(5); H = ones(3); J = imfilter(I,H,'valid'); size(J)

Expected output:

ans = [3 3]

Using imfilter with coding agents

Open a RunMat example with live inputs, then ask the agent to explain how imfilter changes the result.

Run a small imfilter example, explain the result, then change one input and compare the output.

FAQ

Which computation mode is the default?⌄

Correlation is the default. The conv option reverses the kernel before filtering.

What do same, full, and valid mean?⌄

Same preserves image extent, full includes every overlap, and the RunMat-gated valid form includes only complete overlaps.

How do I set constant padding?⌄

Pass a real numeric scalar. The RunMat-gated fill keyword optionally accepts a following scalar and defaults to zero.

Does imfilter support color or N-D images?⌄

Yes. Trailing image axes are filtered independently when the public at-most-2-D H is extended by singleton axes.

Does imfilter normalize H?⌄

No. H is used exactly as supplied; fspecial can generate normalized smoothing kernels.

What if H is larger than A?⌄

Same and full use selected padding; valid may return a zero-length axis.

Can imfilter fuse into elementwise chains?⌄

No. It is a standalone filtering operation with an optional provider hook.

Are logical images supported?⌄

Yes. Logical values are computed numerically and rounded/clamped back to logical output; the prior editable reference's double-output claim did not match runtime behavior.

Related Image functions

Filters

filter2 · fspecial

Color

gray2rgb · hsv2rgb · im2double · im2uint16 · im2uint8 · ind2rgb · lab2rgb · rgb2gray · rgb2hsv · rgb2lab

Io

imfinfo · imread · imwrite

Image

imhist

Source you can read

Every RunMat function's source is public. Read exactly how imfilter is executed, line by line, in Rust.

  • View the source for imfilter in Rust on GitHub
  • Learn how the RunMat runtime works
  • Found a bug? Open an issue with a minimal reproduction.

About RunMat

RunMat is a runtime that executes MATLAB-syntax code fast on any GPU. The runtime is free for individuals, including freelancers; students and faculty at an academic institution, for teaching or research there; contributors to an open-source project, for work on that project; organizations with 250 or fewer people and US$10M or less in annual revenue; and anyone, for non-production use. See runmat.com/license.

  • RunMat automatically optimizes your math for GPU execution on Apple, Nvidia, and AMD hardware. No code changes needed. Simulations that took hours now take minutes.
  • Start running code in seconds. RunMat runs in the browser, on the desktop, or from the CLI. No license server, no IT ticket.

Getting started · Benchmarks · Pricing

Download RunMat

Download RunMat for full performance, or use RunMat in your browser for zero setup.

Download RunMatOpen Sandbox
On this page
  • Syntax
  • Inputs
  • Returns
  • Errors
  • Mode, padding, and shape
  • Class and residency
  • Examples
  • Smooth with zero padding
  • Replicate the image border
  • Keep every kernel overlap
  • Reverse the kernel
  • Wrap image borders
  • Complete overlaps only
  • Using imfilter with coding agents
  • FAQ
  • Related Image functions
  • Filters
  • Color
  • Io
  • Image
  • Source you can read
  • About RunMat