일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | ||||
4 | 5 | 6 | 7 | 8 | 9 | 10 |
11 | 12 | 13 | 14 | 15 | 16 | 17 |
18 | 19 | 20 | 21 | 22 | 23 | 24 |
25 | 26 | 27 | 28 | 29 | 30 | 31 |
Tags
- 계묘년
- 영화 후기
- 대학원생
- 생물정보학
- 심리학
- 젖비단그물버섯
- 토양미생물학
- 탐조
- 더 웨일
- 청도요
- Rstuido
- 영화 리뷰
- 영화
- 갓생
- 둠칫새
- 파이썬
- Cannon PowerShot G7 X Mark III
- 바운새
- R
- 철학
- 영화 해석
- RStudio
- 코딩
- 영화 일기
- 생명과학 균학 미생물학 Biology Mycology Microbiology
- 외생균근균
- 곤줄박이
- mushroom #mushrooms #mushroomhunting #mushroomphotos #mushroomphotography #mycology #mycologist #fungi #fungalecology #fungaldiversity #fantasticfungi #버섯 #탐균 #버섯탐사
- 에리히 프롬
- 토양학
Archives
- Today
- Total
워라밸 중독자
[Python] 사진 및 영상 배경 쉽게 제거해주는 프로그램 (무료, 여러개 한번에) 본문
https://github.com/nadermx/backgroundremover
GitHub - nadermx/backgroundremover: Background Remover lets you Remove Background from images and video with a simple command li
Background Remover lets you Remove Background from images and video with a simple command line interface that is free and open source. - GitHub - nadermx/backgroundremover: Background Remover lets ...
github.com
일단 파이썬이 깔려있어야 사용 가능합니다.
저는 윈도우 11에 wsl2 설치후 Ubuntu에 프로그램을 설치했습니다. 다음 코드를 입력하여 설치했습니다.
pip install --upgrade pip
pip install backgroundremover
설치 시간이 좀 걸립니다.
이제 여러 새 사진의 배경을 한번에 지워보겠습니다.
# cd를 이용해 사진이 들어있는 폴더로 이동
# backgroundremover -i "input 파일 이름 또는 절대 경로" -o "output 파일 이름 또는 절대 경로"
backgroundremover -i "IMG_7971.JPG" -o "IMG_7971_modified.JPG"
backgroundremover -i "IMG_8072.JPG" -o "IMG_8072_modified.JPG"
backgroundremover -i "IMG_8089.JPG" -o "IMG_8089_modified.JPG"
backgroundremover -i "IMG_8138.JPG" -o "IMG_8138_modified.JPG"
ㅋㅋㅋㅋㅋㅋ처참하네요... 하지만 논문에 실을 실험 사진처럼 단순하거나 배경이 깔끔한 사진에 대해선 잘 작동한답니다^^
#!/bin/bash
# 입력 디렉토리와 출력 디렉토리 설정
input_dir="/home/snyoo/pictures/"
output_dir="/home/snyoo/pictures/output/"
# 출력 디렉토리가 없는 경우 생성
mkdir -p "$output_dir"
# 모든 파일에 대해 loop 실행
for file in "$input_dir"*; do
# 파일 이름에서 확장자를 제외한 부분 추출
filename=$(basename "$file")
# output 파일 경로 설정
output_file="${output_dir}${filename}"
# backgroundremover 명령어 실행
backgroundremover -i "$file" -o "$output_file"
echo "Processed: $file -> $output_file"
done
'코딩, 딱 지금이 시작할때! (코딱지)' 카테고리의 다른 글
[R] 데이터 전처리 - 열 또는 행 이름 확인 및 변경하기 (0) | 2023.01.19 |
---|---|
[Python] 특정 문자열 목록을 포함하는 모든 파일 찾아서 복사하기 (0) | 2023.01.17 |
[R] 사용자 설치 패키지 모두 삭제 (0) | 2023.01.12 |
[R] 인덱싱(indexing) - 데이터에서 원하는 값 추출 (0) | 2023.01.12 |
[R] 데이터프레임 쓰기 및 읽기 - read.table(), write.table() (0) | 2023.01.07 |