Search found 15 matches

by mviereck
2020-03-03T10:34:49-07:00
Forum: Users
Topic: -contrast-stretch 0% for sequence of images
Replies: 3
Views: 3619

Re: -contrast-stretch 0% for sequence of images

Thank you for your hints and ideas! Meanwhile I have an attempt that seems to be pretty close, maybe you can confirm or correct it. With "-evaluate-sequence mean" I generate a mean image of the image sequence that should get the same auto-level, auto-gamma or stretch-contrast 0% for each image. From...
by mviereck
2019-10-26T05:09:13-07:00
Forum: Users
Topic: -contrast-stretch 0% for sequence of images
Replies: 3
Views: 3619

-contrast-stretch 0% for sequence of images

I want to apply '-contrast-stretch 0%' on a sequence of similar images. The automation of the special '0%' argument leads to more or less intensive changes for different images in the sequence. I would like to have the same change on all images. A possible attempt I think of: - Generate a mean image...
by mviereck
2018-12-28T05:28:03-07:00
Forum: Users
Topic: Get inner rectangle of wonky image on transparent background
Replies: 36
Views: 16273

Re: Get inner rectangle of wonky image on transparent background

I found a case where the approach outlined above does not give the greatest local maximum: https://up.picr.de/34692972sa.png I see two possible attempts: 1.) Use the resulting geometry as a seed geometry for an inside-outwards approach. 2.) - Grep the splitting column. - Return to last detected isla...
by mviereck
2018-12-26T15:56:50-07:00
Forum: Users
Topic: Get inner rectangle of wonky image on transparent background
Replies: 36
Views: 16273

Re: Get inner rectangle of wonky image on transparent background

I've decided not to develop a new script. My own use case is already covered with border check only in trim_hard2 script and I want to spend more time on the microscopic capture processing project where this inner rectangle detection is a part of. I believe an ImageMagick option as outlined in my pr...
by mviereck
2018-12-25T15:32:32-07:00
Forum: Users
Topic: Get inner rectangle of wonky image on transparent background
Replies: 36
Views: 16273

Re: Get inner rectangle of wonky image on transparent background

Thanks for your example. I'll give it a try to create a script based on connected-components. I am fighting with several details, however, the concept is clear: Target is the greatest possible inner rectangle without border color. - Find the greatest island with connected-components. - Remove side w...
by mviereck
2018-12-25T04:20:06-07:00
Forum: Users
Topic: Get inner rectangle of wonky image on transparent background
Replies: 36
Views: 16273

Re: Get inner rectangle of wonky image on transparent background

You can filter the CCL output to export only the coords of the largest regions. What do you mean with "filtering CCL output"? I can get a list of islands with: convert image -define connected-components:verbose=true -connected-components 4 info: I can work on this output with grep, sort and other t...
by mviereck
2018-12-24T16:27:39-07:00
Forum: Users
Topic: Get inner rectangle of wonky image on transparent background
Replies: 36
Views: 16273

Re: Get inner rectangle of wonky image on transparent background

The proposed algorithm for empty rows etc works fine if there are only two candidate solutions. When there are more than two, the splitting may result in a rectangle that needs further splitting, which would happen in the next pass of the loop. If two small pieces are larger in total than one large...
by mviereck
2018-12-22T19:43:47-07:00
Forum: Users
Topic: Get inner rectangle of wonky image on transparent background
Replies: 36
Views: 16273

Re: Get inner rectangle of wonky image on transparent background

I've found a solution that finds rectangles in previously failing images. I'll call it trim_hard3 The previous trim_hard2 only checks sides. This can fail in cases where more than one center is possible and the checked geometry contains entirely empty rows or columns. This can be seen well in the la...
by mviereck
2018-12-22T14:29:29-07:00
Forum: Users
Topic: Get inner rectangle of wonky image on transparent background
Replies: 36
Views: 16273

Re: Get inner rectangle of wonky image on transparent background

I am of the opinion that IM should have a basic algorithm that trims excess background are around the outside of an image. This will cover the most likely use case of the majority of image that people need to trim, such as slight rotations or simple borders. I agree. The current solution will likel...
by mviereck
2018-12-22T07:39:56-07:00
Forum: Users
Topic: Get inner rectangle of wonky image on transparent background
Replies: 36
Views: 16273

Re: Get inner rectangle of wonky image on transparent background

I have a script, innerTrim2.bat, that uses a similar approach. It trims the edge that has the lowest proportion of boundary colour, and repeats. It seems you have written your answer while I was editing mine. :-) Now your and my script follow the same logic. The difference is only that my script ca...
by mviereck
2018-12-21T06:22:59-07:00
Forum: Users
Topic: Get inner rectangle of wonky image on transparent background
Replies: 36
Views: 16273

Re: Get inner rectangle of wonky image on transparent background

One of those is wrong. A rectangle that starts at $Left and ends at $Right has a width of (Right-Left+1). Similarly height. Good catch, thank you! Same bug took place in calls of cropcolorcount. Is fixed now and updated above. ------------ I've created two test images where the my maximal-color app...
by mviereck
2018-12-20T16:52:53-07:00
Forum: Users
Topic: Get inner rectangle of wonky image on transparent background
Replies: 36
Views: 16273

Re: Get inner rectangle of wonky image on transparent background

I have thought about testing each side first to see which one has the most background pixels and then only chopping that one side. The repeat that. I've written a second version trim_hard2 based on exactly that approach: #! /bin/bash showimage() { display "${1:-}" & } cropcolorpermille() { # Functi...
by mviereck
2018-12-20T04:15:20-07:00
Forum: Users
Topic: Get inner rectangle of wonky image on transparent background
Replies: 36
Views: 16273

Re: Get inner rectangle of wonky image on transparent background

Then it circulates around the alpha channel sides checking each row and column to see if the mean is less than 1 (in the range 0 to 1). If so, then it crops both alpha channel and the images. [...] My method seems to trim more than you want on your image above. I assume that happens because the che...
by mviereck
2018-12-19T06:39:53-07:00
Forum: Users
Topic: Get inner rectangle of wonky image on transparent background
Replies: 36
Views: 16273

Re: Get inner rectangle of wonky image on transparent background

Thank you! I admit that I am overcharged with -morphology and also have difficulties to understand find4corn and innertrim scripts. I have developed a bit of code on my own that does the job fairly well. It is not foolproof and not fast, but I understand it ;-). (With the innercrop script I had some...
by mviereck
2018-12-13T11:44:59-07:00
Forum: Users
Topic: Get inner rectangle of wonky image on transparent background
Replies: 36
Views: 16273

Get inner rectangle of wonky image on transparent background

First, thanks for ImageMagick! It is a great tool I begin to discover yet. I want to get the coordinates of the inner rectangle of a wonky image on a transparent background. The inner rectangle I look for is the biggest possible one without transparency. Background: I make image stackshots with same...