Tag Info

Increase performance creating Mandelbrot set in python

I'm going to reuse some parts of the answer I recently posted here on Code Review. Losing your Loops (Most) loops are damn slow in Python. Especially multiple nested loops. NumPy can help to ...
• 7,184
Accepted

Converting JPG images to PNG

Not much to improve upon, just some minor housekeeping. Help the end user! If I was using this script, and forgot to put one or both of the filepaths when calling the script, there would be this ...
• 9,642

Converting JPG images to PNG

The variable names path1 and path2 are bad since they are not as descriptive as possible. They should rather be ...
• 21k
Accepted

Julia Fractal Drawing in C++

Unqualified names The namespace identifier is missing from a lot of names - e.g. std::sqrt, std::log, ...
• 58.1k

Python 3 function to rotate an image 90°

You can use NumPy module that's good with arrays and matrices. It has a built-in for exactly that purpose - ...
• 886
Accepted

Python 3 function to rotate an image 90°

I believe the time complexity is $O(n^2)$, but I'd like to know for sure There's a general method for figuring out the time complexity for a piece of code, which is to annotate each line with the ...
• 49.2k
Accepted

Resizing image but keeping aspect ratio

Your algorithm to calculate the final image dimensions could be improved by simplifying the logical process that you use to determine the final size. Fundamentally, there are two dimensions you are ...
• 96.8k

Increase performance creating Mandelbrot set in python

This will cover performance, as well as Python style. Save constants in one place You currently have the magic numbers 2000 and 3000, the resolution of your image. Save these to variables perhaps ...
• 51k

Fastest way to clamp an integer to the range 0-255

Conclusion 2011-12-05: I tried all of the suggestions again with VS 2010 Express. The generated code didn't change much, but the register assignments did which affected the overall results. A slight ...
• 1,806
Accepted

Change desktop background

These using directives are not needed and can be safely removed: ...
• 74.7k
Accepted

Detecting a certain amount of violet in an image

Try using HSV/HSL to represent color instead of RGB. You can then define violet as some hue range, e.g. 250° to 310° and similarly for saturation and lightness/value. Always use a ...
• 2,909

Converting JPG images to PNG

Apart from what's already mentioned I would like to point out that the file super.picture.jpg will be converted to super.png ...
• 271
Accepted

Slow image generation

Like I said before, the reason why this takes a lot of time is because the number of steps is proportional to the square of the number of disks. But there are some other improvements to be made to ...
• 8,960

Get image from other site in PHP

Your code is vulnerable to LFI and XSS. http://localhost/yourscript.php?url=../../../../../../etc/passwd This would load the local file /etc/passwd and display ...
• 24.9k

Classifying image by file extension within a PDF creator

Naturally, you can use a dictionary to map extensions to file types: "jpg" -> ImageFileType.Jpeg "jpeg" -> ImageFileType.Jpeg "...
• 107k
Accepted

OpenCL implementations of IQZZ and IDCT for MJPEG

Indent your loop bodies. Actually check ret - you're uselessly assigning and discarding it every time. Use better variable names: avoid single letters (...
• 831

Determine if an image is opaque or transparent

I don't know how good the C# compiler and runtime optimize this code out of the box, so here is what I would try: Load bitmap.Width, ...
• 21k

Julia Fractal Drawing in C++

There's already a good answer, so I'm just going to raise a couple of small points. I had the same thought as Toby Speight about saving the square root of abs(z), ...
• 24k

Maze generator & animator in Python

This is a tip I make a lot, but if you have a collection that's simply tracking "membership", and you don't care about order, you should consider using a Set over a List. I think this is the case for ...
• 16.1k

Checking CSS code for best practices when mimicking

Here is my CSS Well, no, actually. That's your HTML - it just happens to have some style attributes. Which it shouldn't have. So step one, separate CSS and HTML. ...
• 32.9k
Accepted

Imaging with getPixel() and loops

The ´var´ keyword: From the C# Programming Guide: The var keyword can also be useful when the specific type of the variable is tedious to type on the keyboard, or is obvious, or does not add to ...
• 5,553

Determine if an image is opaque or transparent

Readability The readability of the code could be slightly improved by adding a new line before the unsafe. Assigning the ...
• 50k
Accepted

Determine if an image is opaque or transparent

Performance can definitely be improved, but it's a case of how far you want to take the tradeoff. First, though, note that Bitmap is ...
• 24k

Processing an image to extract green-screen mask

Use conditional indexing: ...
• 12.2k
Accepted

Hough transform algorithm - Idiomatic c++

Here are some suggestions for improving the code. Use all required #includes The code uses vector but doesn't include the ...
• 64.5k
Accepted

Speed optimization for transparent gradient blend algorithm

There are a number of things you could do to make this faster and better. Use a pointer rather than array references The code currently computes a pixelIndex and ...
• 64.5k

Mandelbrot image generator

Several things: I compiled your code on my Linux host (Centos 7) using gcc version 4.8.3 via the command line: ...
• 371
Accepted

Processing an image to extract green-screen mask

There's a simpler way to create the empty image using numpy.zeros_like: empty_img = numpy.zeros_like(img) As Austin Hastings ...
• 293