matlab/matlab-agentic-toolkit / skills-catalog/image-processing-and-computer-vision/matlab-process-images
matlab-process-images
VerifiedLoad this first for any MATLAB task involving images, photos, scans, frames, volumes, or visual data — reading, writing, filtering, enhancing, denoising, sharpening, deblurring, thresholding, segmenting, masking, detecting, counting objects, removing backgrounds, measuring, registering, stitching, aligning, cropping, resizing, or transforming. Covers image I/O (TIFF, PNG, JPEG, RAW, HDR), histograms, edge detection, color, morphology, deep learning for images, quality assessment, and 3-D volumes. Also for image problems (dark, noisy, blurry, low contrast, uneven lighting, hazy, color cast) or data exploration (folder of images). Includes medical imaging I/O (DICOM, NIfTI, NRRD, medicalVolume) and large/blocked images (blockedImage, whole-slide). Skip if the user just wants you to look at an image, with no MATLAB work. Not for Simulink video-block models, C/C++/CUDA code generation or GPU deployment of a network, or point clouds. Hyperspectral and visual inspection have sibling skills.
references/dicom-anonymization.md
View on GitHub# DICOM Anonymization
Remove patient-identifying information from DICOM files using `dicomanon`. Works with Image Processing Toolbox (R2006a+).
## dicomanon — Anonymize a DICOM File
Removes or replaces patient health information (PHI) per DICOM PS3.15 standard.
```matlab
dicomanon(inputFile, outputFile)
```
## Single File Anonymization
```matlab
dicomanon("input.dcm", "anonymized.dcm");
```
## Key Options
| Option | Purpose | Example |
|--------|---------|---------|
| `'keep'` | Preserve specific DICOM tags | `'keep', {'StudyDescription', 'PatientSex'}` |
| `'update'` | Replace tags with specified values | `'update', struct('PatientName', 'ANON')` |
```matlab
% Keep certain fields during anonymization
dicomanon("input.dcm", "output.dcm", ...
keep={'StudyDescription', 'PatientSex', 'PatientAge'});
% Update specific fields with custom values
dicomanon("input.dcm", "output.dcm", ...
update=struct('PatientName', 'Subject001', 'PatientID', 'S001'));
```
## Batch Anonymization with Shared UIDs
When anonymizing a DICOM series, all files must share the same `StudyInstanceUID` and `SeriesInstanceUID` so viewers group them as one volume. Generate UIDs once with `dicomuid`, then apply to all files via `'update'`.
```matlab
inputFolder = "path/to/dicom/series";
outputFolder = "path/to/output";
% Generate consistent UIDs for the entire series
sharedUIDs = struct();
sharedUIDs.StudyInstanceUID = dicomuid;
sharedUIDs.SeriesInstanceUID = dicomuid;
% Get all DICOM files
allFiles = dir(fullfile(inputFolder, '*.dcm'));
% Anonymize each file with shared UIDs
for i = 1:numel(allFiles)
inFile = fullfile(inputFolder, allFiles(i).name);
outFile = fullfile(outputFolder, allFiles(i).name);
dicomanon(inFile, outFile, update=sharedUIDs);
end
```
## dicomuid — Generate Unique DICOM Identifiers
```matlab
uid = dicomuid; % Returns a unique DICOM UID string
```
Use `dicomuid` to create new UIDs for `StudyInstanceUID`, `SeriesInstanceUID`, or `SOPInstanceUID` when you need consistent identifiers across a batch.
## Pattern: Anonymize with Custom Patient Info
```matlab
customInfo = struct();
customInfo.StudyInstanceUID = dicomuid;
customInfo.SeriesInstanceUID = dicomuid;
customInfo.PatientName = 'ANONYMIZED';
customInfo.PatientID = 'ANON_001';
allFiles = dir(fullfile(inputFolder, '*.dcm'));
for i = 1:numel(allFiles)
inFile = fullfile(inputFolder, allFiles(i).name);
outFile = fullfile(outputFolder, allFiles(i).name);
dicomanon(inFile, outFile, update=customInfo);
end
```
## Pattern: Verify Anonymization
```matlab
% Read original and anonymized metadata
infoOrig = dicominfo("original.dcm");
infoAnon = dicominfo("anonymized.dcm");
% Check key PHI fields are removed/changed
fprintf("Original PatientName: %s\n", infoOrig.PatientName.FamilyName);
fprintf("Anonymized PatientName: %s\n", infoAnon.PatientName.FamilyName);
fprintf("UIDs match: %d\n", strcmp(infoOrig.StudyInstanceUID, infoAnon.StudyInstanceUID));
```
## Common Mistakes
| Mistake | Correct Approach |
|---------|-----------------|
| `dicomanon` on series without `'update'` for UIDs | Each file gets different UIDs — viewers treat each slice as separate study. Use shared UIDs via `'update'` |
| Manually blanking DICOM fields one-by-one | Use `dicomanon` — handles all PHI tags per standard |
----
Copyright 2026 The MathWorks, Inc.
----
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| writing-skillsobra/superpowersUse when creating new skills, editing existing skills, or verifying skills work before deployment | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| xlsxanthropics/skillsUse this skill any time a spreadsheet file is the primary input or output. This means any task where the user wants to: open, read, edit, or fix an existing .xlsx, .xlsm, .xltx, .csv, or .tsv file (e.g., adding columns, computing formulas, formatting, charting, cleaning messy data); create a new spreadsheet from scratch or from other data sources; or convert between tabular file formats. Trigger especially when the user references a spreadsheet file by name or path — even casually (like "the xlsx in my downloads") — and wants something done to it or produced from it. Also trigger for cleaning or restructuring messy tabular data files (malformed rows, misplaced headers, junk data) into proper spreadsheets. The deliverable must be a spreadsheet file. Do NOT trigger when the primary deliverable is a Word document, HTML report, standalone Python script, database pipeline, or Google Sheets API integration, even if tabular data is involved. | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |
| shipping-and-launchaddyosmani/agent-skillsPrepares production launches. Use when preparing to deploy to production, or when asking what needs to be in place before shipping. Use when you need a pre-launch checklist, when setting up monitoring, when planning a staged rollout, or when you need a rollback strategy. | Stars: 119k | Updated | Claude CodeCodex | Verified | Install |
| childhoodthedotmack/claude-memBabysit a shipped release after merge, publication, or deployment. Verify published packages, production behavior, installed plugins, and late CI or user reports until the observation window is clean; use babysit for PR readiness before release. | Stars: 118k | Updated | Claude CodeCodex | Verified | Install |