{"id":21875125,"url":"https://github.com/mfbx9da4/seam-carving-js","last_synced_at":"2025-04-15T01:26:18.998Z","repository":{"id":65493560,"uuid":"59056481","full_name":"mfbx9da4/seam-carving-js","owner":"mfbx9da4","description":"Javascript implementation of Seam Carver. Seam Carver is a content-aware image resizing algorithm","archived":false,"fork":false,"pushed_at":"2019-09-06T09:26:59.000Z","size":10447,"stargazers_count":33,"open_issues_count":0,"forks_count":8,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-28T13:21:16.924Z","etag":null,"topics":["algorithm","algorithms","canvas","optimization","seam-carver"],"latest_commit_sha":null,"homepage":"https://mfbx9da4.github.io/seam-carving-js","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mfbx9da4.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-05-17T20:30:13.000Z","updated_at":"2024-04-11T22:07:39.000Z","dependencies_parsed_at":"2023-01-26T03:01:05.663Z","dependency_job_id":null,"html_url":"https://github.com/mfbx9da4/seam-carving-js","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mfbx9da4%2Fseam-carving-js","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mfbx9da4%2Fseam-carving-js/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mfbx9da4%2Fseam-carving-js/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mfbx9da4%2Fseam-carving-js/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mfbx9da4","download_url":"https://codeload.github.com/mfbx9da4/seam-carving-js/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248987496,"owners_count":21194240,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["algorithm","algorithms","canvas","optimization","seam-carver"],"created_at":"2024-11-28T07:14:39.999Z","updated_at":"2025-04-15T01:26:18.972Z","avatar_url":"https://github.com/mfbx9da4.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Seam Carving JS\n\nJavascript implementation of a content-aware image resizing algorithm called seam carving. \u003ca href=\"https://en.wikipedia.org/wiki/Seam_carving\"\u003eSeam carving\u003c/a\u003e crops an image by removing the \"least important\" pixels in an image. An \"unimportant\" pixel is defined as a pixel which is very similar to its surrounding pixels. A seam is a one pixel column in the image which can zig-zag between adjancent columns.\n\n![image](https://user-images.githubusercontent.com/1690659/64417276-b1e5b480-d090-11e9-82ac-c3cfd79b9a85.png)\n![image](https://user-images.githubusercontent.com/1690659/64417322-c2962a80-d090-11e9-8415-ffec76231ea1.png)\n\n\n## Install\n\n    npm install seam-carving-js\n\n## Install for contributors\n\nOSX requires\n\n    brew install pkg-config cairo libpng jpeg giflib\n    xcode-select --install # el capitain only\n\nUbuntu\n\n    sudo apt-get install libcairo2-dev libjpeg8-dev libpango1.0-dev libgif-dev build-essential g++\n\nEveryone\n\n    npm install\n\n## Build\n\n    gulp build\n    \n## Test\n\n    npm run test\n\n## Run demo\n\n    npm install -g local-web-server\n    ws # navigate to http://localhost:8000\n\n## Current optimizations\n- When we remove a seam not all pixels are recalculated instead only pixels either side of the seam are enqueued to be recalculated. If the min sum of the affected pixel has not changed we need not enqueue it's children.\n\n## Potential optimizations\n\n- Move SeamCarver to web worker\n- Iterate arrays in a CPU cache efficient way\n- Keep track of smallest on top row\n- Have three matrices, one for minx, one for vminsum and one for energies so that we can use typed arrays\n- Could convert picture rgba array to [`Uint32Array` rgb number array](https://hacks.mozilla.org/2011/12/faster-canvas-pixel-manipulation-with-typed-arrays/) to save space\n- Do logical deletes on the energy matrix. This way the cost of deletion goes way down, with the cost of finding the neighbor when recalculating going up some. Would have to keep picture array as an array of `Uint8ClampedArray`s.\n- Potentially could add the pixels which we need to recalculate the energy for to a queue of nodes and relax there edges to adjacent pixels. If we do not find a smaller vminsum for any pixel on the queue we do not need to iterate its descendants.\n- There might be a (slightly) better way to remove the seam, with less conversion between coordinates.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmfbx9da4%2Fseam-carving-js","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmfbx9da4%2Fseam-carving-js","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmfbx9da4%2Fseam-carving-js/lists"}