Posts

Showing posts with the label image-processing

How to divide 16-bit integer by 255 with using SSE?

Image
Clash Royale CLAN TAG #URR8PPP How to divide 16-bit integer by 255 with using SSE? I deal with image processing. I need to divide 16-bit integer SSE vector by 255. I can't use shift operator like _mm_srli_epi16(), because 255 is not a multiple of power of 2. I know of course that it is possible convert integer to float, perform division and then back conversion to integer. But might somebody knows another solution... Does this help? – Anton Savin Feb 9 '16 at 6:43 Typically you would divide by 256 (with rounding rather than truncation) - is there some reason why it has to be 255 and not 256 ? – Paul R Feb 9 '16 at 7:25 Maybe this question is interesting fo...

Using (x, y) or (y, x) as pixel access for a C++ image class? [on hold]

Image
Clash Royale CLAN TAG #URR8PPP Using (x, y) or (y, x) as pixel access for a C++ image class? [on hold] I've been wondering what the best (==least prone to user errors) approach would be for a pixel access operator for an image class in C++. operator() is overloaded to access pixels at a location x, y in the image - but the question is should that access be (x, y) or (y, x)? Obviously, I think in principle, we'd be more used to (x, y) for image pixel access, but in mathematics, matrix access is usually (row, col), and since for an image, y is normally the row and x the col, that would result in (y, x). Note this question is only about the API, the access - and not memory storage (row/col-major) or anything like that. operator() x, y In Python, it's common to use NumPy or scipy.ndimage to represent images, which use (row, col) (equal to (y, x)). So, (row, col) access is quite common, because images are 2D arrays or matrices (or 3D in the case of 3-channel images). In OpenC...

Object dimension measurement

Image
Clash Royale CLAN TAG #URR8PPP Object dimension measurement The following image is of a coin (for reference) and a pill. I need to measure the pill's dimensions. The objects are back-illuminated. I followed pyimagesearch.com tutorial for object height and width measurement. The coin has a diameter of 24.97 mm, and the actual dimensions of the pill are 9.43 mm x 19.33 mm. I am getting results with some error ranging from 0.5 mm to 2 mm. As mentioned on the website this is because of distortion and it is to be corrected. Can someone help me in calibrating the camera to remove the distortion effect so that I can measure correct dimensions in mm? I have also tried camera calibration but that is also not working. For camera calibration you need to add an object of known size, or a set of fiducial markers at known distance from each other. There is no way we can tell you how to calibrate your camera with the information you have given here. ...

Octave(or Matlab) sub2ind function convert to python code

Image
Clash Royale CLAN TAG #URR8PPP Octave(or Matlab) sub2ind function convert to python code I implement Matlab 'strel' function to python language. I have some difficulty converting to python code. plz let me know how to convert this function. I think numpy's ravel_multi_index function equal to sub2ind. but it dose not work well. :( Octave code degrees = 30 linelen = 5 deg90 = mod (degrees, 90); if (deg90 > 45) alpha = pi * (90 - deg90) / 180; else alpha = pi * deg90 / 180; endif ray = (linelen - 1)/2; c = round (ray * cos (alpha)) + 1; r = round (ray * sin (alpha)) + 1; line = false (r, c); m = tan (alpha); x = [1:c]; y = r - fix (m .* (x - 0.5)); %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% indexes = sub2ind ([r c], y, x); %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% and My python code here. def strel_line(length,degree): import numpy as np from numpy import pi,cos,sin,tan,fix deg90 = degree % 90 if deg90 > 45: alpha = pi * (90 - deg90) / 180 else: a...

How to create an image using images with FFMPEG?

Image
Clash Royale CLAN TAG #URR8PPP How to create an image using images with FFMPEG? How to create an image using images with FFMPEG? Something like below? -f lavfi -i color=c=white:s=1080x1920 -loop 1 -i 1.png -loop 1 -i 2.png -filter_complex [0:v][1:v]overlay=shortest=1:x=0:y=0[v1];[v1][2:v]overlay=shortest=1:x=10:y=10 -vframes 1 -q:v 5 By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.