Hot answers tagged

4

The biggest simplification and speed improvement would be to avoid using the split function. I would suggest just multiplying the 3-channel image directly. Something like this: cv::multiply(img_hsv, Scalar(1, 1, enhancement_times), img_hsv); Of course, we can’t know for sure which is faster until we compare the running time for each of the alternatives. In ...


2

First of all, I see two problems with your choice of name for the int variable Iterator. For one thing, it goes against the Java coding convention of variable names starting with a lower case letter. And for another, and this might admittedly be more subjective than the first argument, there exists an interface named Iterator in the java.util package, and ...


2

Naming The technique looks like unsharp mask, but performed on the most intense channel of RGB pixel (V component). Although unbrighten_mask might sound like a German word (I don't know any German), I believe it better fits since the code performs similar actions. Unclear usage At the moment the code has contradictory interface. On one hand, it seems like an ...


2

This function has too many responsibilities, as is evident by the number and variety of arguments. We have mixed filesystem and image processing, making a function that's hard to reuse (e.g. in a GUI program, where we might want to preview the result before saving) and hard to unit-test. If we split it, we have smaller, more readable functions. Other ...


2

Improvements: The return type is strange and awkward enough that it needs a comment to explain it! What benefit does returning a reference to an array have over simply returning a pointer to the first element? It would be better to return an object. It might simply contain a pointer and length, but it means you could update it to support dynamically loaded ...


1

The following code part could be inefficient for large sets: .OrderByDescending(x => x.count) .First(); We don't need sorting at all, we need just to find an item with the maximum value. Let's create a couple of extension methods for this. For reference types: private static TSource MaxItem<TSource, TKey>(this IEnumerable<TSource> source, ...


1

You don't need to use a dictionary. Instead, order by the count directly: var champion = test.GroupBy(t => t[1]) .OrderByDescending(g => g.Count()) .First(); Note that this might do the count per group several times while sorting. For a very large number of items, you could improve it by storing the result in a ...


1

This can be simplified by using destructuring assignment into an array, followed by simple assignment into the object obj. While it may not be much more efficient it can eliminate the need to use the forEach method. const val = "someValue,display"; const [columnVal, displayValue] = val.split(","); const obj = {columnVal, display: displayValue === "...


1

I'd write increment = (<|> (Just 1)) . fmap (+1) You can probably also write reverseBySecond = flip $ comparing snd if you don't mind getting EQ for equal pairs.


1

Please don't post random slapped-together lines of code that couldn't possibly compile to CodeReview. We strongly prefer code that compiles, even if all the dependencies aren't available to us. This method will never compile. In canonical Java, there is whitespace after a , String building is typically cleaner when done with a StringBuilder. A simple helper ...


1

Avoid hardcoding translation strings to 16 bytes There's no need to set the size of the strings to 16 bytes, just store them as pointers to const char instead of arrays of char: typedef const char *tr_chars_t[TR_SIZ]; Store all languages in an array For each language you have a separate variable holding the translations strings, and you have a long if-then-...


1

Stingy makes many good points, though I'd disagree about calling any variable "i" - in my opinion you should always try to find a meaningful name for anything in your program. In this case, I think the variable represents a character position in the string, so I'd probably call it something like "currentCharPos" (I'd even consider "...


Only top voted, non community-wiki answers of a minimum length are eligible