프로그래밍 방식으로 이미지를 만화 화하는 방법은 무엇입니까?
내 앱은 내가 만화 화하고 싶은 사람들의 사진과 동영상으로 작동합니다. 따라서 수동으로 수행하는 알고리즘 (이미지 조작 클래스가있는 제품에는 C ++ / Qt 사용) 또는 자체 앱에서 호출하여 사용할 수있는 일부 CLI 프로그램이 필요합니다.
다음은 사용할 수있는 몇 가지 알고리즘입니다.
- 만화 같은 색상 팔레트를 얻기위한 중앙값 또는 반복 상자 흐림 필터
- 편집 : 양방향 필터링은 사용자의 요구에 더 적합해야합니다.
- 일부 가장자리 유형을 향상시키는 최소 필터 (0 번째 백분위 수)
- RGB 컬러 큐브의 작은 서브 큐브 또는 구를 사용한 컬러 이미지 분할
- Sobel 커널 또는 8 방향 에지 추적과 같은 에지 감지를 사용하여 분할 된 이미지에 대한 일반적인 에지 향상
- 가장자리가 향상된 블러 링 / 중앙값 필터링 이미지 합성
이것들은 매우 기본적이며 구현하기 매우 쉽습니다. 중앙값 및 상자 흐림 필터는 커널 반경에 대한 선형 시간 복잡성으로 구현할 수 있습니다.
추가 편집 :
Huang의 알고리즘에 대한 아이디어를 얻으면 상자 흐림 필터를 구현하는 것이 맛있는 케이크 조각입니다.
읽을 거리:
- 빠른 중앙값 및 양방향 필터링 (PDF 가져 오기)
- 중앙값 필터링 상수 시간 (PDF 가져 오기) 참고 : Mono / SIMD를 사용하여 히스토그램 병합을 가속화하기 위해 C #으로 구현했지만 직경이 ~ 60 픽셀을 초과 할 때 O ( r ) 알고리즘 보다 비슷한 수의 추가 / 구독 명령어 (손익분기 점), C ++ 구현이 SIMD를 활용하는 데 훨씬 더 적합 할 것입니다.
다른 읽기 자료로는 세분화 및 가장자리 추적을위한 Gonzalez & Woods의 디지털 이미지 처리 (이전 버전 인 것 같음)가 있습니다. 8-way 가장자리 추적은 머리를 구부리기가 정말 어려울 수 있습니다 (픽셀 또는 픽셀 간 가장자리 중에서 선택하고 가장자리에 고정하는 방법). 몇 가지 코드를 공유하게되어 기쁘지만 100 줄짜리 코드가 여기에 정확히 맞지 않습니다.
toonyphotos.com 처럼 rotoscopy를 시도 할 수 있습니다 .
Blender 용 비 사실적 렌더러 를 구현하기위한 오픈 소스 (Google Summer of Code) 프로젝트 인 Freestyle 을 확인하는 것이 좋습니다. 다음은 카툰 모드의 출력 예입니다. (출처 : sourceforge.net )
If there's some set of parameters which achieve the desired effect in the GIMP's Cartoon filter (or some other combination of filters) it can be run in a batch processing mode.
I have not done this myself, but thinking about two steps that might give the image a cartoonish look.
Detect edges, and draw a fairly fairly thick line (a few pixels) on those edges.
Decrease the number of colours in your image.
Not sure if this will help, but this tutorial for Photoshop suggests doing the following:
- Open your image in Photoshop
- Filter > Blur > Gaussian Blur. Set the radius at 3.0 or higher, to taste.
- Edit > Fade Gaussian Blur. A window will pop up . . . set the mode to darken. You may also need to lower the opacity.
Here's the result.
I imagine that you could do something similar in your program.
It's relatively easy to do. Here are the steps:
bilateral filtering to simplify/abstract the photo. You may want to separate the bilateral filter so that it's faster. Perform the bilateral filter in 1d along the gradient and then along the normal to the gradient.
detect the edges. For instance, using a Difference of Gaussians algo. You may want to use the DoG in the gradient direction and smooth it following the flow lines. To get the flow lines, you would need to get the Edge Tangent Flow (ETF) which you can get via structure tensor.
quantize the colors. Actually, you quantize the luminance to simulate cel shading aka toon shading.
blend the abstracted image afer quantize and the edges you detected.
This will give you a rendered image that looks like a cel shaded cartoon.
I made some free software (for win64) that does exactly this at: http://3dstereophoto.blogspot.com/p/painting-software.html
The name of the software is "The Cartoonist" and you can see it in action here: http://3dstereophoto.blogspot.com/2018/07/non-photorealistic-rendering-software_9.html
Those are links to my blog which primarily deals with 3d photography (depth maps, photogrammetry, etc).
actually i dont know a tool but you can look to osg (openSceneGraph)
there is a osgFX library and there is cartoon effect... maybe you can inspire from that library...
maybe (i dont know) imagemagick has many features, maybe it has a feature like that but i dont know...
참고URL : https://stackoverflow.com/questions/1357403/how-to-cartoon-ify-an-image-programmatically
'Nice programing' 카테고리의 다른 글
java.lang.IndexOutOfBoundsException : 소스가 대상에 맞지 않습니다. (0) | 2020.11.21 |
---|---|
Java 8에서 추상 클래스와 인터페이스의 차이점은 무엇입니까? (0) | 2020.11.21 |
CSS로 플로트 탑을 어떻게 만들 수 있습니까? (0) | 2020.11.21 |
XMPP의 "명단"은 무엇입니까? (0) | 2020.11.21 |
장고 등록 후 자동으로 로그인하는 방법 (0) | 2020.11.21 |