
Security News
The Hidden Blast Radius of the Axios Compromise
The Axios compromise shows how time-dependent dependency resolution makes exposure harder to detect and contain.
motion-vector-analyzer
Advanced tools
Analyze motion vectors in JPEG and PNG images using gradient analysis
A comprehensive TypeScript library that analyzes motion vectors in JPEG and PNG images using gradient analysis, Sobel filters, and optical flow algorithms with advanced visualization capabilities.
# Install the library
npm install motion-vector-analyzer
# Or for development
git clone https://github.com/yourusername/motion-vector-analyzer.git
cd motion-vector-analyzer
npm install
import { MotionVectorAnalyzer } from 'motion-vector-analyzer';
const analyzer = new MotionVectorAnalyzer();
// Load and analyze an image
await analyzer.loadImage('path/to/your/image.jpg');
await analyzer.analyzeMotionVectors();
// Save visualization
await analyzer.saveVisualization('output/vectors.png');
The Motion Vector Analyzer is designed to be used as a TypeScript/JavaScript library in your applications.
import { MotionVectorAnalyzer } from './src/MotionVectorAnalyzer';
const analyzer = new MotionVectorAnalyzer();
// Load and analyze an image
await analyzer.loadImage('path/to/image.jpg');
analyzer.analyzeMotionVectors(smoothingWindow = 3, downsampleFactor = 4);
// Save basic visualization
await analyzer.saveVisualization('output/vectors.png', {
scale: 15,
color: '#FF0000',
showMagnitude: true,
vectorDensity: 4
});
// Enhanced arrow rendering
await analyzer.saveVisualization('output/enhanced.png', {
arrowStyle: 'filled',
thickness: 2,
antiAliasing: true,
colorScheme: 'direction',
scale: 15
});
// Interactive HTML visualization
await analyzer.createInteractiveVisualization('output/interactive.html', {
mode: 'arrows',
interactive: true,
showTooltips: true,
enableSelection: true,
realTimeAdjustment: true,
scale: 15,
colorScheme: 'direction'
});
// Multiple visualization modes
const modes = ['arrows', 'heatmap', 'streamlines', 'particles', 'contours'];
for (const mode of modes) {
await analyzer.createInteractiveVisualization(`output/${mode}.png`, {
mode,
interactive: false,
scale: 10,
vectorDensity: 2
});
}
// Export in different formats
await analyzer.exportVisualization('output/publication.svg', {
format: 'svg',
width: 1200,
height: 900
});
// Load two images for optical flow
await analyzer.loadImagesForOpticalFlow('previous.jpg', 'current.jpg');
// Analyze with optical flow
analyzer.analyzeMotionVectorsWithOptions({
algorithm: 'optical_flow',
flowType: 'dense',
forwardBackward: true
});
// Save results
await analyzer.saveVisualization('output/optical_flow.png', {
scale: 20,
arrowStyle: 'filled',
antiAliasing: true
});
});
await analyzer.saveVisualizationWithBackground(
'path/to/image.jpg',
'output/overlay.png'
);
*_vectors.png: Vector field visualization on white background*_overlay.png: Vectors overlaid on the original image*_colormap.json: Color map data for further analysis*_interactive.html: Interactive web visualization with zoom, pan, and tooltips*_export.svg: Scalable vector graphics for publications*_heatmap.png: Magnitude heat map visualization*_streamlines.png: Flow streamline visualization*_particles.gif: Animated particle flow*_contours.png: Magnitude contour linesscale: Scale factor for vector display (default: 10)color: Arrow color in hex format (default: '#FF0000')backgroundColor: Background color (default: '#FFFFFF')showMagnitude: Vary opacity based on vector magnitude (default: true)vectorDensity: Skip factor for vector display (default: 1)arrowStyle: Arrow style - 'simple', 'filled', or 'outlined' (default: 'simple')thickness: Line thickness (scales with magnitude)antiAliasing: Enable smooth line rendering (default: true)colorScheme: Color mapping - 'magnitude', 'direction', or 'custom' (default: 'magnitude')customColorMap: Custom color gradient arraycolorBlindFriendly: Use accessible color palettes (default: false)Extends VisualizationOptions with:
mode: Visualization mode - 'arrows', 'heatmap', 'streamlines', 'particles', 'contours'interactive: Enable interactive features (default: true)zoom: Initial zoom level (default: 1)pan: Initial pan offset {x, y}showTooltips: Show vector information on hover (default: true)enableSelection: Allow vector selection (default: true)realTimeAdjustment: Enable parameter controls (default: true)animationSpeed: Speed for particle animationsanimationFrames: Number of frames for GIF exportparticleCount: Number of particles for flow visualizationcontourLevels: Number of contour linesstreamlineDensity: Density of streamline seedingformat: Export format - 'png', 'svg', 'html', 'gif'width: Output width (for SVG/HTML)height: Output height (for SVG/HTML)quality: Output quality (0-100)animationFrames: Number of animation framesinteractive: Generate interactive HTML (for HTML format)smoothingWindow: Size of smoothing kernel (default: 3)downsampleFactor: Factor to reduce vector field resolution (default: 1)opticalFlowOptions: Advanced optical flow configurationPlace your JPEG or PNG images in the examples/ directory and run:
npm run dev
The program will process all valid images and save results to the output/ directory.
├── src/
│ ├── modules/
│ │ ├── ImageLoader.ts # Image loading and preprocessing
│ │ ├── GradientAnalyzer.ts # Sobel filter implementation
│ │ ├── VectorFieldCalculator.ts # Vector field math
│ │ ├── Visualizer.ts # Basic image generation
│ │ ├── EnhancedVisualizer.ts # Enhanced visualization features
│ │ └── OpticalFlowAnalyzer.ts # Optical flow algorithms
│ ├── types.ts # TypeScript interfaces
│ ├── MotionVectorAnalyzer.ts # Main analyzer class
│ ├── test-enhanced-visualization.ts # Enhanced feature tests
│ └── index.ts # CLI entry point
├── examples/
│ ├── enhanced-visualization-demo.js # Complete feature demo
│ └── [sample images] # Test images
├── output/ # Generated results
├── ENHANCED_VISUALIZATION_GUIDE.md # Detailed feature guide
└── package.json
# Install dependencies
npm install
# Run tests
npm test
# Build the project
npm run build
# Run linter
npm run lint
For development and testing, you can use the included CLI:
# Development mode (processes examples/)
npm run dev
# Build and run
npm run build && npm start
# Build the project
npm run build
# Login to npm (if not already logged in)
npm login
# Publish the package
npm publish
npm testMIT
FAQs
Analyze motion vectors in JPEG and PNG images using gradient analysis
We found that motion-vector-analyzer demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
The Axios compromise shows how time-dependent dependency resolution makes exposure harder to detect and contain.

Research
A supply chain attack on Axios introduced a malicious dependency, plain-crypto-js@4.2.1, published minutes earlier and absent from the project’s GitHub releases.

Research
Malicious versions of the Telnyx Python SDK on PyPI delivered credential-stealing malware via a multi-stage supply chain attack.