Diagnoses and enhances camera image quality from Image Acquisition Toolbox or USB Webcams. Discovers camera capabilities at runtime, analyzes images for brightness/contrast/sharpness/noise/color issues, suggests hardware setting adjustments, and applies Image Processing Toolbox enhancements.
Ships in test-and-measurement. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them; scripts run unread.
Diagnose image quality issues from any connected camera and improve them through a combination of hardware setting adjustments and software post-processing. Operates in a hardware-first, software-second philosophy: always try to fix at the source before resorting to post-processing.
scripts/diagnoseImageQuality.m — reusable diagnostic function; takes an image, returns a struct of quality metrics with assessmentsdetect_matlab_toolboxes first to confirm Image Acquisition Toolbox and Image Processing Toolbox are installedcheck_matlab_code on any script before executing itAPI selection: When Image Acquisition Toolbox is available, always prefer videoinput over other interfaces like webcam(). videoinput exposes more properties (via propinfo), supports bulk frame acquisition (getdata), and provides FramesAcquiredFcn for streaming. Use webcam() only when Image Acquisition Toolbox is not installed and the user has the MATLAB Support Package for USB Webcams instead.
Connect to the camera and enumerate all available properties:
% For videoinput (preferred when Image Acquisition Toolbox is available):
vid = videoinput(adaptorName, deviceID, format);
vid.ReturnedColorSpace = 'rgb'; % Critical for YUY2 cameras
src = getselectedsource(vid);
props = properties(src);
% For webcam (fallback when only USB Webcams support package is installed):
cam = webcam();
props = properties(cam);
Classify each discovered property by function:
| Problem Domain | Common Property Names |
|---|---|
| Brightness/Exposure | Exposure, ExposureTime, ExposureMode, Brightness, Gain, BacklightCompensation |
| Focus | Focus, FocusMode |
| Color | WhiteBalance, WhiteBalanceMode, Hue, Saturation, ColorEnable |
| Contrast/Tone | Contrast, Gamma, Sharpness |
Record valid ranges for each property. Report discovered capabilities to the user.
For properties that do NOT match the classification table above, apply the advanced property investigation protocol:
videoinput sources, use propinfo(src, propName) to determine type, constraint, range, and read-only statusFor videoinput objects (preferred):
% Warm up the camera (critical — first frames are often blank or poorly exposed)
preview(vid);
pause(2);
closepreview(vid);
% Capture the reference image
baselineImg = getsnapshot(vid);
imshow(baselineImg);
title("Baseline Image");
For webcam objects (fallback):
% Warm up the camera (critical — first frames are often blank or poorly exposed)
preview(cam);
pause(2);
closePreview(cam);
% Capture the reference image
baselineImg = snapshot(cam);
imshow(baselineImg);
title("Baseline Image");
Note: snapshot() is webcam-only. For videoinput, use getsnapshot(vid). Both webcam and videoinput objects support preview().
Record current property values as baseline for comparison.
Before running diagnostics, identify what the user is trying to fix:
Map the user's concern to one of these categories:
diagnoseImageQuality.m): brightness, contrast, sharpness, noise, color balance, backlightingIf the concern is an extended one, note it for dynamic evaluation in Step 4.
Run the diagnostic script (always — provides the standard baseline):
addpath("scripts");
results = diagnoseImageQuality(baselineImg);
disp(results);
The function returns a struct with fields:
brightness — mean intensity, assessmentclipping — highlight clipping (% pixels ≥ 250) and shadow clipping (% pixels ≤ 5), assessmentcontrast — standard deviation, assessmentsharpness — Laplacian variance, assessmentnoise — estimated noise level, assessmentcolorBalance — R/G and B/G ratios, assessmentbacklightRatio — center-vs-border brightness ratio, assessmentEach field has .value (numeric or struct) and .assessment ("OK", "Problem", or "Severe").
Identify the primary issue(s) — focus on fields assessed as "Problem" or "Severe".
Dynamic evaluation for extended concerns: If the user's concern from Step 3 is not covered by the standard 6 metrics, generate inline MATLAB code to evaluate it. See references/diagnosis-guidance.md § "Extended Metrics" for evaluation patterns and code templates. Report the extended metric result alongside the standard results.
Map diagnosed problems to available camera properties using the decision table below. Only suggest adjustments for properties the camera actually has.
Apply settings, re-capture, and compare metrics. Change one property at a time.
For videoinput objects (preferred):
% Example: increase exposure for dark image
src.Exposure = src.Exposure + 2;
newImg = getsnapshot(vid);
newResults = diagnoseImageQuality(newImg);
For webcam objects (fallback):
% Example: increase exposure for dark image
cam.Exposure = cam.Exposure + 2;
newImg = snapshot(cam);
newResults = diagnoseImageQuality(newImg);
Note: With videoinput, set properties on the source object (src), not the videoinput object. Use getsnapshot(vid) instead of snapshot().
Iterate if needed until metrics improve or hardware options are exhausted.
Based on remaining issues after hardware adjustment, apply IPT functions in the correct order:
imlocalbrighten, imadjust, gamma correctionlocallapfilt, adapthisteq on luminance channelimsharpen — always lastenhanced = baselineImg;
% Example: brighten a backlit image
enhanced = imlocalbrighten(enhanced, 0.8);
% Example: enhance local contrast
enhanced = locallapfilt(enhanced, 0.3, 1.5);
% Example: sharpen (last step)
enhanced = imsharpen(enhanced, 'Radius', 1.5, 'Amount', 1.0);
Display before/after comparison:
montage({baselineImg, enhanced}, 'Size', [1 2]);
title("Before vs After Enhancement");
Summarize the full workflow:
Generate a reusable .m function file that the user can call for future captures without the agent. Write it to a user-specified folder if provided, otherwise to the current MATLAB working directory (pwd). Do NOT write it to the skill's scripts/ folder — that is reserved for the skill's own helper functions.
After writing the file:
check_matlab_code on it to verify syntaxThe function should:
ReturnedColorSpace = 'rgb' if the camera outputs YUY2 or other non-RGB format| Diagnosed Problem | Hardware Fix (if available) | Software Fix (IPT) |
|---|---|---|
| Subject too dark (backlit) | BacklightCompensation ↑, Exposure ↑, Brightness ↑ | imlocalbrighten, inverted imreducehaze |
| Overall underexposed | Exposure ↑, Gain ↑, Brightness ↑ | Gamma correction (.^ 0.7), imadjust |
| Overall overexposed | Exposure ↓, Brightness ↓ | imadjust with output range [0 0.8] |
| Low contrast | Contrast ↑, Gamma adjust | locallapfilt, adapthisteq on luminance |
| Motion blur | Exposure ↓ (faster shutter) | imsharpen (limited), deconvolution |
| Out of focus | Focus adjust (if available) | imsharpen (limited help) |
| High noise | Gain ↓, Exposure ↑ instead | imgaussfilt, imnlmfilt, wiener2 |
| Color cast | WhiteBalance adjust, WhiteBalanceMode=auto | Manual white point correction |
| Washed out | Gamma ↓, Contrast ↑ | imadjust, locallapfilt |
Replace placeholders with discovered values. Only include enhancement steps that measurably improved metrics.
function img = acquireEnhancedImage()
%acquireEnhancedImage Capture and enhance image from <camera name>.
% img = acquireEnhancedImage() returns an enhanced RGB image.
vid = videoinput('<adaptor>', <deviceID>, '<format>');
vid.ReturnedColorSpace = 'rgb';
src = getselectedsource(vid);
% Tuned hardware settings
src.<Property1> = <value>;
src.<Property2> = <value>;
% Warm up
preview(vid);
pause(2);
closepreview(vid);
% Capture
img = getsnapshot(vid);
delete(vid);
% Enhancement pipeline (only steps that helped)
img = imlocalbrighten(img, <amount>);
img = imgaussfilt(img, <sigma>);
end
Naming: use acquireEnhancedImage as default, or ask user for a preferred name. Follow lowerCamelCase. See references/enhancement-guidance.md § "Generating Reusable Functions" for parameterization and optional-input guidance.
localtonemap requires single input — always convert with im2single() first; passing uint8 throws an errorpreview() or discard initial snapshots before capturingadapthisteq (CLAHE) needs a single-channel image — apply on V channel (HSV) or L channel (Lab), not directly on RGBimlocalbrighten only lifts dark regions — preserves already-bright areas; preferred over global brightness increase for backlit scenesReturnedColorSpace = 'rgb' — many USB webcams (e.g., Microsoft LifeCam) only output YUY2. Without setting vid.ReturnedColorSpace = 'rgb', getsnapshot returns raw YCbCr data misinterpreted as RGB, causing wrong colors in display AND incorrect results from IPT functions and diagnostic metricssnapshot vs getsnapshot — snapshot(cam) is webcam-only; getsnapshot(vid) is for videoinput objects. They are not interchangeableclosePreview vs closepreview — webcam uses camelCase closePreview(cam); videoinput uses lowercase closepreview(vid). Using the wrong case throws "Undefined command/function"getdata — for multi-frame capture with videoinput, use getdata(vid, N) instead of looping getsnapshot. It fetches N frames in one call with less overhead and lets the adaptor run at full speedfullfile for file saves — when saving images or generated files, use fullfile(pwd, 'filename.png') to avoid path resolution errors across platformsCopyright 2026 The MathWorks, Inc.
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
/test-and-measurement:matlab-enhance-camera-imagefrom test-and-measurement
npx claudepluginhub matlab/matlab-agentic-toolkit --plugin test-and-measurement13 skills in this plugin
/matlab-build-industrial-hmiBuild industrial-grade SCADA/HMI dashboards in MATLAB following industrial-HMI conventions (ISA-101-aligned): gray-field philosophy, alarms at source, write safeguards, fixed-range trends, drill-down layout. Produces a real App Designer app (.mlapp, or plain-text .m+.xml on R2026b+) by handing serialization to the matlab-build-app skill when available, and falls back to a programmatic .m app otherwise. Use when wrapping OPC UA / Modbus / MQTT / OSI PI / PI AF monitoring scripts into a live operator app, building plant overviews, designing operator dashboards, or any time a user asks for a "SCADA dashboard", "HMI", "plant dashboard", "operator screen", or "industrial monitoring app" in MATLAB. Trigger on: SCADA, HMI, industrial dashboard, plant overview, operator screen, uigauge, uilamp, alarm banner, gray-field, ISA-101, OPC UA dashboard, setpoint, write safeguards, alarm visualization, OSIsoft PI, AVEVA PI, PI Server, PI Data Archive, PI AF, PI Asset Framework, piclient, afclient.
/matlab-call-nidaqmxTranslate NI-DAQmx C function signatures into correct calldaqlib MATLAB calls. Use when the user mentions calldaqlib, any DAQmx* C function name (DAQmxCfgSampClkTiming, DAQmxExportSignal, DAQmxSetStartTrigRetriggerable, DAQmxGetSampClkRate, etc.), or needs NI-DAQmx functionality not exposed by the daq object. Covers: projection rules (taskHandle implicit, output pointers become return values, buffer-size args, enum-as-string), multi-task semantics, start() clobber, device-level empty-daq workaround, dictionary returns, string getter placeholder, array getter placeholder. Trigger contexts: low-level DAQ, escape hatch, retriggerable acquisition, shared timebase, export signal, connect terminals, external sample clock, trigger configuration, NI driver, C function translation.
/matlab-connect-arduinoDiscover, configure, and connect to Arduino boards from MATLAB using the Arduino Support Package. Use this skill when the user wants to set up an Arduino board, connect to Arduino hardware, find connected boards, scan serial ports, configure Arduino libraries, or any task that requires an Arduino connection as a prerequisite (e.g., blink LED, read sensor, read digital pin, read analog pin, write pin, plot sensor data, scan I2C, use ultrasonic sensor, control servo, read temperature, read voltage, data logging from hardware). Triggers on: arduino, board setup, COM port, serial port, hardware connection, Arduino Nano, Arduino Uno, Arduino Mega, Arduino Micro, Grove, sensor setup, I2C scan, ultrasonic, servo, readDigitalPin, writeDigitalPin, readVoltage, writePWMVoltage, temperature sensor, air pressure, pin read, pin write, analog input.
/matlab-connect-bluetooth-low-energy-deviceDiscover and connect to Bluetooth Low Energy (BLE) peripheral devices from MATLAB. Use this skill when the user wants to scan for BLE devices, connect to a BLE peripheral, read or write BLE characteristics, subscribe to notifications, or any task that requires a BLE connection as a prerequisite (e.g., read sensor data over BLE, monitor heart rate, log accelerometer, stream data from wearable, IoT device communication). Triggers on: BLE, Bluetooth Low Energy, blelist, ble device, BLE characteristic, GATT, service UUID, scan for devices, BLE sensor, subscribe notify, BLE read, BLE write, peripheral device, BLE connect, wireless sensor.
/matlab-create-custom-arduino-libraryUse when the user wants to use Arduino sensors or peripherals from MATLAB that are not directly supported by the MATLAB Support Package for Arduino Hardware. Triggers on requests to create, wrap, or expose a custom Arduino library to MATLAB. Also triggers on indirect questions like "How do I read humidity in MATLAB?" or "How do I display text on an LCD from MATLAB?" where the answer requires a custom Arduino add-on library. Covers: custom addon creation, third-party Arduino library integration, LibraryBase class, C++ header files, DependentLibraries, arduinoioaddons namespace, I2C/SPI/GPIO peripheral wrappers.
/matlab-discover-hardwareDiscovers connected MATLAB-supported hardware devices, searches by capability, and checks required support packages and add-ons. Use when the user asks what hardware is connected, finds a device that supports a capability (e.g., CAN, analog input), or checks if required support packages or add-ons are installed. Does NOT connect to, configure, or acquire data from devices — defers to device-specific skills for usage workflows.Other plugins' skills for the same job