This tag is for questions related to the loading, formatting, saving, compression, and display of data representing pictures.
5
votes
1answer
61 views
Preloading images in JavaScript
I'm working on a little game where you press a button and a new image appears. There's a glitch every time you ask a new image to display and it occurred to me that I should preload the necessary ...
5
votes
1answer
46 views
Utilizing HTML5 Canvas to apply color theme to .png icons
Because we have a mix of both icons for core items and .png icons for custom items, I've developed an easy way to theme them (alter the color) all of them easily that will work across all browsers.
...
6
votes
2answers
156 views
Image processing algorithm
This is code I need to maintain. I'm trying to make this as an example for code gone bad, for C programmers going to C++.
Please provide any comment you can. The original code is about 40 pages ...
5
votes
1answer
54 views
How to speed up window leveling (brightness, contrast)?
I have to apply window leveling on Canvas Medical Image (CR). I have to get a pixel array from C# Component.lutArr, which is a lookup table array coming as a C# component and which I use in ...
0
votes
3answers
51 views
Image Carousel in JavaScript
I created a very basic "image projector" that shows the current one and shows the next on clicking into the image.
And yeah, it works, but I don't think that's a very elegant way to do it. Any advice ...
4
votes
1answer
60 views
Security: Scale and cache images
Specification
A simple PHP script resizes images on-the-fly. The script is called by the web server's 404 handler to return a scaled version of the original. For example, if the original image is at:
...
3
votes
3answers
110 views
Loop optimization for image processing
I have this piece of code that is running too slow. I was wondering if anyone can help me optimize it as I can't seem to find any more shortcuts. I'm not sure if using List<> is going to help me ...
5
votes
1answer
117 views
Fastest image upload into SQL database
Hello I am trying to upload an image (screenshot from desktop) to SQL database as fast as possible. I would like to optimize my current procedure in terms of speed:
bmpScreenshot = new ...
6
votes
2answers
173 views
Ghost4J PDF to image conversion
The primary goal of this code is to convert a PDF file to images. I also create a directory under C:/Media based on a combination of the PDF name and current date and insert the uploaded PDF to the ...
9
votes
1answer
148 views
Rotating greyscale images
For educational purposes I wrote a little piece of code to rotate greyscale images as "low level" as possible, that is, not using any rotate() function, but doing the math. I was wondering if it could ...
6
votes
1answer
55 views
Optimize YUV channel splitting function
The input pointer *data contains the data that needs to be split into different arrays and put in yuvInput. Each pixel is 32 bytes 4 * 8. Note the (j*4) to break it up per pixel segment. The 4th ...
6
votes
1answer
80 views
Reddit RepostFinder Bot
I've been making a bot for Reddit. It finds reposts (based on image MD5 comparing) and posts a small comment on the thread (that part will be later, right now it downloads images and compares MD5). If ...
4
votes
2answers
69 views
Calculating luma of a rect in an image of .yuv format
I'm trying to get the average luma of an area in an YUV image in the Android camera. I have come up with the following code which I think is correct and produces consistent results.
private static ...
9
votes
2answers
99 views
Assigning width and height to specify image dimension using jQuery
After testing my site against GTMetrix, I get warnings on not specifying image dimensions. I am working on a WordPress site. Here is my solution:
My first solution was:
// Specify image ...
8
votes
3answers
858 views
PPM/PGM Image processing library in Haskell
EDIT: I changed encodePixel to use Builder, so this is how it looks:
encodePixel ASCII (ColorPixel r g b) = mconcat $ fmap toAscii [r,g,b]
where toAscii l = intDec l <> charUtf8 ' '
and ...
6
votes
1answer
167 views
How do I make this duplicate sort algorithm run faster?
I've written a program whose code is included at the end of the question. It is working fine but the performance time is approximately 5 minutes and 29 seconds. I am dealing with 1090 images.
This ...
6
votes
1answer
125 views
Getting list of colours from image in lab format
I need to write a bit of code that will get a list of the RGB colours in an image and then translate them into a NumPy array of lab colours. I have managed to do this, but I would like to learn how I ...
6
votes
4answers
590 views
Is there a faster way to compare if 2 images are the same?
Bitmap image1 = null;
Bitmap image2 = null;
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e) //first image open
{
OpenFileDialog openDialog = ...
8
votes
2answers
73 views
Recolour a shape
I am starting with a starting colour, a target colour and a starting position in an image. I want to change every contiguous pixel if it is close to the starting colour.
Imagine a stop sign. It has ...
1
vote
1answer
83 views
Game map tiles generation with php
I am working on a browser strategy game as a hobby and came up with a decision to use a tile-based map for the world map.
I have several questions so far:
I am using double-cache (file and apc) ...
3
votes
1answer
77 views
Improving rendering performance of 2D Tile Game
I want to see if I can make any improvements to the rendering methods that are currently written. I've noticed when profiling this project that the CPU was allocating a fair percentage of the time ...
4
votes
2answers
80 views
Rotate an image by 90 degrees
Looking for review, good practices, optimizations, clean code tips etc.
final class Pixel {
private final int color;
public Pixel(int color) {
this.color = color;
}
public ...
0
votes
2answers
60 views
Screenshot-scaling code
Please review for readability.
/*
Takes a screenshot of the current tab, then scales it to width and height.
Returns null if the tab is smaller than width and height.
Crops the screenshot to maintain ...
4
votes
1answer
99 views
Commenting in Python
I am struggling with commenting and variable naming. My teacher says my comments need to be more explanatory and explicit. He says my variable names are also sometimes confusing. I was just wondering ...
5
votes
1answer
60 views
Does this image-processing break SRP?
I'm writing a small library to do some image processing on GPU for WinRT - however I'm not sure if such design breaks SRP.
One class loads and saves image, renders and maintains filters - isn't it ...
2
votes
1answer
70 views
image rate system
I'm developing a site, which has an image upload section, and members and like the image, but a member can like it only once..
I have a table, named uploads which has columns id, ...{more ...
4
votes
1answer
60 views
Bilinear interpolation
The following code is to enlarge pictures using bilinear interpolation. What can be modified in the function of slow_rescale to make it more efficient? I expect to modify it from the view of ...
5
votes
3answers
163 views
Improve this image file browser (remove redundancy)?
Let me start by saying that the code works as is but I think it has a lot of redundancy. It is written this way as I kept getting nullpointerexceptions if I try to put the fileCounter > gameDiff ...
3
votes
2answers
154 views
Image loader/writer design (no API, pure C++ on Windows)
I have an image loader, now only for bitmaps. I'm a little confused because I want to split my code to different classes, one for writing a BMP data to a file (WRITER), one for loading BMP data from ...
2
votes
0answers
71 views
Replace subimage by its average value
I have the input image in, and the mask image lev (which label each pixel as a number from 1 to nlevels, nlevels=4). I need to get image out, which from each region in==lev will be replaced by its ...
4
votes
1answer
124 views
JPEG extraction script
Here is a program that I've wrote to extract JPEGs from a file. It reads a file that contains the image data and separates it into individual images.
import hashlib
inputfile = 'data.txt'
marker = ...
1
vote
1answer
310 views
SSE Intrinsics Gaussian Blur Approximation
The following is the current iteration of a gaussian blur approximation code I am using.
A typical naive convolution operation is O(N*M), where N is the number of image pixels, and M is the number of ...
1
vote
1answer
171 views
Is this a good method for validating uploaded images?
I have attempted to write a method that checks that images being uploaded are valid.
public function checkValidImages(){
$errors = array();
$allowedImages = ...
5
votes
4answers
383 views
Code review for Image Flip algorithm in C
This is the algorithm I am using to flip an image in-place. Thought so far it works perfect, I would like if any one can spot any potential problems or give any points on improvement and optimization. ...
3
votes
1answer
418 views
Encoding a screenshot to JPEG and saving it to a memorystream
I have done some tests of my code, which I got help to improve here before. The code simply takes a screenshot of a selected process window, encodes it to JPEG (if I want), saves it to a memorystream ...
5
votes
3answers
148 views
Image-processing algorithm on mobile device
I have written the following algorithm (for Android/NDK) to apply levels to a bitmap. The problem is that it is really very slow. On a fast device such as the SGSIII, it can take up to 4 seconds for ...
6
votes
1answer
125 views
Optimize bilinear resizing C/C++ algorithm
I have the next bilinear resizing algorithm, and even though I use fixed point is still quite slow for my requirements. In the past I tried to cache some values in tables but the improvement was of a ...
0
votes
0answers
122 views
Fetch images from an array of URLs and upload to S3
I'm uploading arrays of image URLs to save to S3. The code works, but it is not executing asynchronously. Time stamping to the console appears to show that first all the images are fetched and ...
6
votes
1answer
57 views
Image-downloader/wallpaper setter
I'm making an image-downloading app that sets the image as the device wallpaper. For this I used the class:
ImageDownloader.java
This class has a function which accepts a URL and an ImageView. It ...
2
votes
1answer
589 views
JPEG compression and DCT algorithm verification
Here is the code I am using to apply DCT on 8x8 blocks, which I'm not sure is correct. I have tried to follow Wikipedia's discrete cosine transformation (DCT) formula as closely as possible. Please ...
1
vote
1answer
180 views
Responsive image solution
I just made this responsive image solution, but I'm not sure if it's the best way to do what I'm trying to achieve. Use cases can be found at http://responsimage.com/.
/* responsimage.com v0.2.3 */
...
38
votes
8answers
8k views
Fastest way to clamp an integer to the range 0-255
I'm working on some image processing code that can generate pixel values outside of the normal range of 0 to 255, and I'd like to clamp them back into the valid range. I know that there are saturating ...