w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
Replace image by standard image on 404
From the jQuery documentation: The event handler must be attached before the browser fires the error event, which is why the example sets the src attribute after attaching the handler. Also, the error event may not be correctly fired when the page is served locally; error relies on HTTP status codes and will generally not be triggered if the URL uses the file: protocol. If I understood this, it means if you execute your .each loop in the $(document).ready function all images has their error already fired.

Categories : Javascript

Cant get standard deviation to work in C
Your mean calculation will fail as you are doing integer division, and this will then make the subsequent std dev calculation incorrect. Change: mean = sum/count; to mean = (float)sum/count; so that the division is performed using floating point arithmetic. You might also want to print the value of mean at this point to check that it looks reasonable.

Categories : C

Weighted Standard Deviation in PHP code
You can't calculate it exactly because the standard deviation formula computes the difference between each element against the average. But you can get a good approximation by the following formula: std_dev_a3 = (n1 - 1)*pow(std_dev_a1, 2) + (n2 - 1)*pow(std_dev_a2, 2) std_dev_a3 = sqrt(std_dev_a3 / (n1 + n2 - 2)) You mentioned that you use this approach because you have memory leak. You can avoid a memory leak storing your data into a frequency table: {[8] => 3, [9] => 4, ..., [14] => 2} With this data structure, you can calculate the standard deviation: // This should be provide by your data $freq = array(8 => 3, 9 => 4, 11 => 1, 12 => 2, 13 => 1, 14 => 2); // Calculate mean $mean = 0; $n = 0; foreach ($freq as $value => $count) { $mean += $val

Categories : PHP

r conditional standard deviation on 2 matrices
The problem with your approach is that you're trying to pass a matrix (B) to your function foo, which is expecting two vectors (x and y). You could try something like this instead: sapply(1:ncol(A), function(i) sd(B[as.logical(abs(A[,i])),i])) [1] 1.5275252 0.7071068 Which is basically just a loop... Another approach would be if your A and B objects are dataframes, you can use mapply: A <- as.data.frame(A) B <- as.data.frame(B) mapply(foo, A,B) V1 V2 1.5275252 0.7071068 Benchmarking the two approaches, the sapply route is maybe twice as fast. I can imagine that this is because sapply is just taking a vector of integers as arguments and processing matrices whereas the mapply approach is taking dataframes as arguments (dataframes are slower than matrices and m

Categories : R

SAS: Calculate Standard Deviation on-the-fly in datastep
Standard deviation does not have any meaning for a single bet; it would only have meaning either for a player in total, or for a player over a particular period of time. The choice of a particular definition (ie, what time period, etc.) is well out of scope for Stack Overflow; that would be a CrossValidated question. However, calculating the standard deviation itself is certainly in scope: proc means data=have; class username; var stake; output out=want stddev=stake_stddev; run; You can add a type username; statement if you don't want the across-all-players stddev. You can also ask for a mean or sum or whatever you find useful. If you want to do this across time periods, you either can create a dataset that has a time period variable, repeats rows as needed so they're in every time

Categories : Sas

How to calculate and display standard deviation?
I'm wondering if there is a bug under the comment //Obere STD grenze in the middle block? Are you calling the dt when you want to be calling stdSpec? double.Parse(dt.Rows[i - 1][0].ToString() double.Parse(stdSpec.dtCoords.Rows[i - 1][0]

Categories : C#

standard deviation of a UIImage/CGImage
To further expand on my comment above. I would definitely look into using the Accelerate framework, especially depending on the size of your image. If you image is a few hundred pixels by a few hundred. You will have a ton of data to process and Accelerate along with vDSP will make all of that math a lot faster since it processes everything on the GPU. I will look into this a little more, and possibly put some code in a few minutes. UPDATE I will post some code to do standard deviation in a single dimension using vDSP, but this could definitely be extended to 2-D float *imageR = [0.1,0.2,0.3,0.4,...]; // vector of values int numValues = 100; // number of values in imageR float mean = 0; // place holder for mean vDSP_meanv(imageR,1,&mean,numValues); // find the mean of the vect

Categories : IOS

How to calculate a pooled standard deviation in R?
What you're trying to do requires a more general formula which will make it easier. No loops are required. df$df <- df$n-1 pooledSD <- sqrt( sum(df$sd^2 * df$df) / sum(df$df) )

Categories : R

How to calculate the standard deviation for every 100 points in a nx3 vector?
I would do this: M = randn(120,3); % substitute this for the actual data; 3 columns N = 100; % number of elements in each set for which std is computed cols = size(A,1); for n = 1:ceil(cols/N) row_ini = (n-1)*N+1; row_fin = min(n*N, cols); % the "min" is in case cols is not a multiple of N std(A(row_ini:row_fin,:)) end The "for" loop could probably be vectorized, if speed is a concern. Edit: If you want to store all results in a three-column matrix, you just modify the "std" line and add some initialization, like this: M = randn(120,3); % substitute this for the actual data; 3 columns N = 100; % number of elements in each set for which std is computed cols = size(A,1); n_max = ceil(cols/N); result = repmat(NaN,ceil(cols/N),3); % initialize for n = 1:n_max row_ini = (n-1)*N+1

Categories : Matlab

Standard deviation calculation not returning expected value
Your calculation is incorrect. Standard deviation is based on the sum of the squares of the difference to the mean. You are simply summing the squares of the data values. You must first calculate the mean (ie the average), then once you know that you can calculate the standard deviation using this value. The correct procedure is (quoting from wikipedia): To calculate the population standard deviation, first compute the difference of each data point from the mean, and square the result of each: Next, compute the average of these values, and take the square root: Basically, you can't calculate the standard deviation "as you go".

Categories : Java

iterating over lists finding standard deviation of each point
positives = [b for b in A if b >= 0] doesn't do what you think it does. b would be a list of 7 elements, how can a list of 7 elements be greater than 0? numpy makes this easy: import numpy as np import numpy.ma as ma A = [[-9999.0, -9999.0, -9999.0, -9999.0, -9999.0, -9999.0, -9999.0], [-9999.0, -9999.0, -9999.0, -9999.0, -9999.0, -9999.0, -9999.0], [0.040896, 0.018690, 0.005620, -9999.0, 0.038722, 0.018323, -9999.0], [0.039443, 0.017517, 0.003460, -9999.0, 0.035526, 0.011692, -9999.0], [-9999.0, 0.017963, 0.005264, -9999.0, 0.03788, 0.014316, -9999.0]] A = np.array(A) sigmas = [] for b in A: bmask=ma.masked_array(b,mask=np.greater_equal(b,0)) b=b[bmask.mask] print b sigmas.append(np.std(b)) gives [] [] [ 0.040896 0.01869 0.00562 0.038722 0.01

Categories : Python

calculation variance and standard deviation in a single parse
The formula is not quite right. Here you have a description of an online algorithm which you can use.

Categories : C

Passing mean and standard deviation into dnorm() using Rcpp Sugar
The sugar dnorm is only vectorized in terms of the first argument. To simplify (it is slightly more involved, but we don't need to concern ourselves with this yet here), the call dnorm(xx, 0.0, 1.0) uses the overload NumericVector dnorm( NumericVector, double, double ) And the second call tries to use something like NumericVector dnorm( NumericVector, NumericVector, NumericVector ) which is not implemented. We could implement it, it would have to go high enough in our priority list. In the meantime, it is easy enough to write a small wrapper, like (this does not handle argument lengths, etc ...) : NumericVector my_dnorm( NumericVector x, NumericVector means, NumericVector sds){ int n = x.size() ; NumericVector res(n) ; for( int i=0; i<n; i++) res[i] = R::dnor

Categories : R

"AttributeError: sqrt" when calculating a simple standard deviation
It seems that the problem is the dtype set as object. Even if numpy allows it, it is generally a bad idea, as you lose most internal optimizations. The exception is present only with the axis keyword : >>> import numpy as np >>> a = np.arange(10).reshape(5,2) >>> b = np.arange(10, dtype=object).reshape(5,2) >>> np.std(a) 2.8722813232690143 >>> np.std(a, axis=1) array([ 0.5, 0.5, 0.5, 0.5, 0.5]) >>> np.std(b) 2.8722813232690143 >>> np.std(b, axis=1) Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/usr/lib/python2.7/dist-packages/numpy/core/fromnumeric.py", line 2590, in std keepdims=keepdims) File "/usr/lib/python2.7/dist-packages/numpy/core/_methods.py", line 105, in _std

Categories : Python

How to get the standard deviation from gaussian fitted curve in Matlab
The output of fy says that you are fitting a model that consist of a linear combination of two Gaussian functions. The functional form of the model is: fy(x) = a1*exp(-((x-b1)/c1)^2) + a2*exp(-((x-b2)/c2)^2) Remembering that a Gaussian is defined as: f(x) = exp(-(x-x0)^2/(2*s^2)) where: x0 is the mean, s is the std.dev. then the standard deviation of each Gaussian in your model can be computed as (respectively): s1 = c1/sqrt(2) s2 = c2/sqrt(2) See http://en.wikipedia.org/wiki/Gaussian_function for more infomation.

Categories : Matlab

finding standard deviation down a column of data in python
If I understand your question correctly, you have a list of lists, where each sublist contains multiple floats. If you want to compute the standard deviation of a list of numbers: import numpy numpy.std(myList) If you want to compute the standard deviation of all the numbers in the ith "column" of a list of lists: import numpy numpy.std(zip(*myList)[i]) If you want to exclude negative numbers within a column: import numpy import itertools numpy.std([i for i in itertools.izip(*myList)[i] if i>=0]) Hope this helps

Categories : Python

How to transform a dataset's mean and standard deviation with different values per column in R
You can use scale and sweep: sample <- scale(as.matrix(sample),TRUE,TRUE) sample <- sweep(sample,2,sdevs,"*") sample <- sweep(sample,2,means,"+")

Categories : R

improving code efficiency: standard deviation on sliding windows
First off, there's more than one way to do this. It's not the most efficient speed-wise, but using scipy.ndimage.generic_filter will allow you to easily apply an arbitrary python function over a moving window. As a quick example: result = scipy.ndimage.generic_filter(data, np.std, size=2*radius) Note that the boundary conditions can be controlled by mode kwarg. Another way to do this is to use some various striding tricks to make a view of the array that's effectively a moving window, and then apply np.std along the last axis. (Note: this is taken from one of my previous answers here: http://stackoverflow.com/a/4947453/325565) def strided_sliding_std_dev(data, radius=5): windowed = rolling_window(data, (2*radius, 2*radius)) shape = windowed.shape windowed = windowed

Categories : Python

Find Region On Image - Automatic Rotate Image OpenCv
I don't know openCV, but you added the C# and C++ tags, which make me suppose that you would accept an algorithm that can be implemented in these languages. To answer your first question: If your images are all similar to the ones you provided, you could do something like this (these are not necessarily sequential steps, they are numbered just for ease of reference): convert to black & white (you could do this only conceptually, if you prefer, by comparing pixel values to a threshold, in what follows) travel along the black outline in vertical, horizontal and diagonal single-pixel steps remember N pairs of coordinates while you travel, so that N is below the expected minimum length, in pixels, of a straight line of your images (you will have to tune N: too long gives you too little

Categories : C#

MATLAB Image Processing - Find Edge and Area of Image
If the end result is an area/diameter estimate, then why not try to find maximal and minimal shapes that fit in the outline and then use the shapes' area to estimate the total area. For instance, compute a minimal circle around the edge set then a maximal circle inside the edges. Then you could use these to estimate diameter and area of the actual shape. The advantage is that your bounding shapes can be fit in a way that minimizes error (unbounded edges) while optimizing size either up or down for the inner and outer shape, respectively.

Categories : Matlab

Obtained incorrect standard deviation and mean values with moving rectangle in VB2010
You should calc mean like mean = mean / (meancount * 3) (there is 3 colors added) and it is better to calc running mean instead of summing all and divide later. I guess there can be more math errors.

Categories : Vb.Net

What is wrong with this code? I am trying to find the width of each items image, if the image is a certain width, apply a class to that item
It will be if(imageH == 506) { $(this).addClass('d'); } else if (imageH == 250) { $(this).addClass('a'); } You are not comparing,you are assigning to imageH which will always return true

Categories : Jquery

JavaFX - Replace standard CheckBox with image
For a tutorial, please, consult the official documentation. There was a lot of new stuff that was added in 2.2. Also, the Introduction to FXML covers pretty much everything you need to know about FXML. Finally, Hendrik Ebbers made an extremely helpful blog post about custom UI controls.

Categories : CSS

creating standard tiles with background image from internet
Unfortunately you'll need to download the image and save it locally. You can then refer to the image from isolated storage string fileName = @"SharedShellContentackgroundTileImage.jpg"; if(TrySaveImage(fileName, "http://foo.com/bar.png")) { Uri uri = new Uri("isostore:/" + fileName, UriKind.Absolute); // Create the tile if we didn't find it already exists. var tileData = new StandardTileData { Title = "My Tile", BackgroundImage = uri, }; } ... private bool TrySaveImage(string fileName, string url) { using (var store = System.IO.IsolatedStorage.IsolatedStorageFile.GetUserStoreForApplication()) { try { var backImage = new Image(); backImage.Height = backImage.Width = 173; backImage.Stretch = St

Categories : C#

Storing and Retrieving Image Path From android application folder On Pre Created SQLite Database & Setting the image to Image View
I would only save the image name in the db and then get the resource identifier with context.getResources().getIdentifier(). Check out this similar question.

Categories : Android

How to get image from an Image Control Type in .net c#, I need to save this image in a file and then use it for later comparing
Previewing Image in ASP.NET Image Control using C# help you to get image from an Image Control Type. You can save the image in the below way. Image bitmap = Image.FromFile("C:\MyFile.bmp"); bitmap.Save("C:\MyFile2.bmp"); You should be able to use the Save Method from the Image Class and be just fine as shown above. The Save Method has 5 different options or overloads. //Saves this Image to the specified file or stream. img.Save(filePath); //Saves this image to the specified stream in the specified format. img.Save(Stream, ImageFormat); //Saves this Image to the specified file in the specified format. img.Save(String, ImageFormat); //Saves this image to the specified stream, with the specified encoder and image encoder parameters. img.Save(Stream, ImageCodecInfo, E

Categories : Dotnet

I am using CIFilter to get a blur image,but why is the output image always larger than input image?
This is a super late answer to your question, but the main problem is you're thinking of a CIImage as an image. It is not, it is a "recipe" for an image. So, when you apply the blur filter to it, Core Image calculates that to show every last pixel of your blur you would need a larger canvas. That estimated size to draw the entire image is called the "extent". In essence, every pixel is getting "fatter", which means that the final extent will be bigger than the original canvas. It is up to you to determine which part of the extent is useful to your drawing routine.

Categories : IOS

php image uplaod show default image when image has not been uploaded
you could use file_exists(), like if( !empty($row['article_image']) AND file_exists(YOUR_PATH . $row['article_image']) ) { //show your image from db } else { //show your default image }

Categories : PHP

How to convert image in to binary image using Image processing with Emgu CV
You can transform image into binary by converting it to grayscale and then apllying threshold after that: var bwImage = colorImg.Convert<Gray, byte>().ThresholdBinary(new Gray(yourThrehold), new Gray(255)); if you have small blobs (salt and pepper noise) you can use median filter -function Median or erode the image (function Erode and that dilating it - funcrtion Dilate)

Categories : C#

Find out the extension of an image, if that image doesn't have any extension
There are java libraries like mime-util or jmimemagic that can detect the file type from the pure content.

Categories : Java

Image tag - hide the image but show the background image
Why cant you use a div/span instead of using img tag and give background to the div/span? I think that is the best thing to do. <div id="image"></div> #image {background-image: url('close16.png') !important;}

Categories : HTML

get pixel color when image view ' s width is set match_parent when image view contain small image
You need to check the dimensions of your bitmap against the bitmap itself. if ((bmp.getHeight() < (int)event.getY() || (bmp.getWidth() < (int)event.getX() ) { // not within range }

Categories : Java

Best way to find image resolution
For newly uploaded images, handle it in your post_save of your model using a signal: django.db.models.signals.post_save To get the size, using PIL, img = Image.open(path_to_file) width, height = img.size For existing images, you probably want to just script something to do this for existing database entries. The alternative to scripting something would be to update your application to try to find the width, height and update them if they are not already set.

Categories : Django

How to find the image location
Because the filename set in the name value is based on user-provided filename and because you don't do any apparent sanitizing of the content or the name, the user could upload a file that is executable by apache and give it a name like: ../../../wickedevilnaughtyfile and get it in the host system's root directory or similar nasty place it doesn't belong and it could be executed from the web browser since http server (apache or whatevs) has access to it since it created the file. This isn't an actual answer, but as demanded in the comments, security threats need more than 600 characters to explain sometimes BTW, if I missed anything in this somewhat terse explanation or got something just wrong, feel free to edit and sign your name right in the answer.

Categories : PHP

find sub-images within an image
If you have only pixels, you'll need image processing algorithms to find sub-images. Your solution will be specific to what the image you are processing looks like. For example, if states are outlined in a certain color, you could try edge detection. If states are each different colors, you could run a flood fill like algorithm to create boundaries for each state. This is a difficult problem. Try computer vision or object recognition for keywords in your research. However, I suggest instead you build up vector files which define boundaries of subimages by hand. If you've only a few to do, this isn't a big deal.

Categories : Java

Image View find by Name
The problem is that you are trying to load an ImageView with an id with the name"id". However, the XML layout file does not have an ImageView with android:id=@+id/id". This means that findViewById() cannot find the ImageView you are requesting. The specified id must exactly match one from your XML view file. Using getResources().getIdentifier() is completely unnecessary. The typical way to get a View object in Java code is to use the R.id class which is generated from your XML layout files when you build your app. In this case, you have defined in your XML layout file a ImageView resource with id imgFirst. So you can call findViewById() like this: ImageView img = (ImageView) findViewById(R.id.imgFirst); This assumes that you have previously called setContentView() to load the XML layou

Categories : Android

Where can I find the pygame.image class?
If related to SDL wrapper from https://bitbucket.org/marcusva/py-sdl2/downloads then see: SDL../sdl2/ext folder has the image.py Assuming you want the pre-compiled C version, see the pygame/src has a image.c and image.doc (documentation). Best of luck!

Categories : Python

Cannot find any of the supported PHP image extensions
It's probably looking for GD and/or ImageMagick extensions. Clearly you have neither installed. The reason they're not installed will depend on who hosts your PHP environment. It seems likely that shared hosting providers may not have them enabled.

Categories : PHP

How to find a checkbox in an Image and here state
Sorry, didn't read all of your code, but it seems to me that you are not using (much) preprocessing. I think some morphological operations might be the first step to take. Implementing a dilation followed by a closing should bring some good results. Those are really simple to program and tend to deliver some very good results. Some side notes: play a lot with the structuring element size and shape if you using binaries, with 0 for black, then the operators will act on the white portion, which is rather counterintuitive (dilate makes your lines skinnier and open closes wholes), so always try both ways. don't fear overdoing it with the size of the structuring elements or the number of iterations, in such a simple application like this, there's not much that can go wrong. here a small

Categories : C#

Need to add a caption to a jpg, python can't find the image
That exception, Cannot identify image file, means that it was able to open the file, but then could not determine what type of image it is. PIL does this by reading the first 16 bytes and seeing if they match any of the well known magic numbers. Could you verify that the file you're trying to read is actually a jpeg? If so, how did you get the version of PIL? If it was compiled on a machine without libjpeg (or whatever the windows equivalent is), it might not support jpegs. See this other question for a possible solution to that issue, though I don't have a windows machine to test with.

Categories : Python



© Copyright 2017 w3hello.com Publishing Limited. All rights reserved.