w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
javascript find correct gray for black and white effect
Use the grayscale formula, like this: var r = parseInt(match[1], 16), g = parseInt(match[1], 16), b = parseInt(match[1], 16), val = Math.floor(0.2126 * r + 0.7152 * g + 0.0722 * b) answer = 'rgb(' + val + ',' + val + ',' + val + ')' return answer This is the formula: Y' = 0.2126R + 0.7152G + 0.0722B Updated fiddle

Categories : Javascript

How to Invert a White image to Black using SVG Filters?
acutally IE has a filter for invert, since version 4.0. checkout http://msdn.microsoft.com/en-us/library/ms533008(v=vs.85).aspx

Categories : CSS

Boolean matrix from simple black and white image
You can do it easily using the numpy and matplotlib library: from matplotlib import pylab matrix = pylab.imread('your_image.png') This will produce a numpy matrix which you can show as an image using: pylab.imshow(matrix) Or see just print the raw matrix by with: print(matrix)

Categories : Python

Loaded textures on android, image is just black and white noise
You could try to change: GLUtils.texImage2D(GLES20.GL_TEXTURE_2D, 0, GLES20.GL_RGB, textureBitmap, GLES20.GL_UNSIGNED_BYTE, 0); to: GLUtils.texImage2D(GLES20.GL_TEXTURE_2D, 0, GLES20.GL_RGBA, textureBitmap, GLES20.GL_UNSIGNED_BYTE, 0); Bitmap class stores it's pixels as an int - 1 byte for each red, green, blue and alpha. So I think the external format of your textureBitmap is RGBA. And from http://www.khronos.org/opengles/sdk/docs/man/xhtml/glTexImage2D.xml: internalformat must match format. No conversion between formats is supported during texture image processing. type may be used as a hint to specify how much precision is desired, but a GL implementation may choose to store the texture array at any internal resolution it chooses. So if you want to use RGB you must either

Categories : Android

How to create colored image mouseover on black/white images (in JQuery)
Hey you are talking about CSS filters... this what you need add this code to your main stylesheet file ;) .portfolio:hover { filter: grayscale(100%); -webkit-filter: grayscale(100%); -moz-filter: grayscale(100%); filter: grayscale(100%); filter: gray; -webkit-filter: grayscale(1); }

Categories : Javascript

creating an image in matlab of 9 small white circles in a large black square
If I understood correctly, try this: % size of each small box. Final image will be 3Nx3N N = 100; % create a circle mask t = linspace(0,2*pi,50); % approximated by 100 lines r = (N-10)/2; % circles will be separated by a 10 pixels border circle = poly2mask(r*cos(t)+N/2+0.5, r*sin(t)+N/2+0.5, N, N); % replicate to build image img = repmat(circle, 3,3); subplot(121), imshow(img) % after applying Gaussian filter h = fspecial('gaussian', [15 15], 2.5); img2 = imfilter(im2double(img), h); subplot(122), imshow(img2)

Categories : Image

OpenCV how to find a list of connected components in a binary image
You need to cv::floodFill the contours returned by cv::findCountours. See this example for findContours, and this one for floodFill

Categories : C++

ggplot black and white
Your y values should be in one variable that correspond to the variable Species in this example. For instance: Change linetype: ggplot(iris) + geom_line(aes(Sepal.Length,Petal.Length,linetype=Species)) + theme_classic() or Change linetype and shape of points: ggplot(iris) + geom_line(aes(Sepal.Length,Petal.Length,linetype=Species)) + geom_point(aes(Sepal.Length,Petal.Length,shape=Species)) + theme_classic()

Categories : R

Convert RGB to black OR white
I would suggest converting to grayscale, then simply applying a threshold (halfway, or mean or meadian, if you so choose) to it. from PIL import Image col = Image.open('myimage.jpg') gry = col.convert('L') grarray = np.asarray(gry) bw = (grarray > grarray.mean())*255 imshow(bw)

Categories : Python

Counting the largest connecting objects/component by using bwlabel
there are several ways to accomplish that, for example histogram the content of the nonzero elements: L=bwlabel(I); [a val]=hist(L(:),1:max(L(:))) val(a==max(a)) will yield the value that is most occuring another way is to use tabulate : a=tabulate(L(:)) a(a(:,2)==max(a(2:end,2)),1) tabulate creates a frequency table of data in vector L(:). The information is arranged as follows: 1st column — The unique values of L 2nd column — The number of instances of each value 3rd column — The percentage of each value etc...

Categories : Matlab

Best practice, to detect if a Mat is black and White in Opencv
Storing grayscale images in RGB format causes all three fields to be equal. It means for every pixel in a grayscale image saved in RGB format we have R = G = B. So you can easily check this for your image.

Categories : C++

How to White-Out/Black-Out Screen on PrintScreenButton Click?
While this is not a recommended practice, it should be possible to listen to the PrtScrn keypress and hide everything until it's released. However, this can easily be circumvented by having another window active and pressing the key. $(document).on('keydown',function(e){ if(e.keyCode == 44) { //print screen button $('body').hide(); } }).on('keyup',function() { $('body').show(); });

Categories : Javascript

Imagick - Make black background white
Try this out: Background Color White: <?php $image = new imagick( "opossum.jpg" ); $image->setimagebackgroundcolor("#fad888"); //Here you can mention the color $image->waveImage( 20, 176); header( "Content-Type: image/jpeg" ); echo $image; ?> Transparent background: <?php $im = new Imagick(); $im->setBackgroundColor(new ImagickPixel('transparent')); $im->readImage('carte_Alain2.svg'); $im->setImageFormat("png32"); header('Content-type: image/png'); echo $im; ?> Also check this Links: http://php.net/manual/en/imagick.setbackgroundcolor.php

Categories : PHP

Combine two images based on a black and white mask
Just use the bitwise_and() function and you're set. The references below include a full working example. References: How to "zero" everything within a masked part of an image in OpenCV OpenCV bitwise_and + mask

Categories : C++

White corner showing on black box with Border-radius
Since overflow: hidden; along with border-radius seems to cause some rendering inconsistencies in some engines (take a look at this), one should use border-radius on both the parent and the child elements to achieve rounded corners. As you have noticed, you still get some wierd results with extra pixels "shining" through. Just reduce the border-radius of the child (or the other way round) to compensate this. blockUI .overlay h1 { border-radius: 2px 2px 0 0; }

Categories : CSS

HCM (High Contrast Mode) white vs black detection
http://www.w3.org/WAI/PF/aria-practices/#accessiblewidget Scroll down to 2.12 Compensate for Background Images when in High Contrast Mode

Categories : Javascript

Imagick convert SVG to PNG - colors replaced by black and white
Try this way: $im = new Imagick(); $im->setBackgroundColor(new ImagickPixel('transparent')); $im->readImageBlob($svgFile); $im->setImageFormat("png24"); $im->writeImage('cylinder.png'); $im->clear(); $im->destroy()

Categories : PHP

How to make transparent background white instead of black when converting PDF to JPG using PythonMagick
If you look at the documentation for the -flatten command-line option, you will see it is an alias for -layers flatten. The -layers flatten command is itself a combination command, which comprises creating a layer of the current background colour the size of the first images canvas, and then composing each layer in turn on top of it. PythonMagick is essentially just a binding layer to the Magick++ C++ interface. The advanced commands that convert provides, are not necessarily replicated in the lower level libraries, as they are really a sequence of commands as described above. So whilst there is no single command for it in the PythonMagick library, the functionality can be replicated. The method you are after is .composite(), the PythonMagick documentation is so limited ( or indeed no

Categories : Python

Why is the text black instead of white when I create a navigation dropdown in an ActionBar?
You need to choose a style for that activity/application. Refer to this example to make the navigation item white.

Categories : Android

matplotlib, set color of lines along a grayscale using numbers from 0. (white) to 1. (black)
For historical reasons, matplotlib expects "floats" to be interpreted as grayscale values to be passed in as strings, which is the reason for your error. For example: import matplotlib.pyplot as plt fig, ax = plt.subplots() ax.plot(range(10), color="0.5") plt.show() Also, for a grayscale colormap, just use plt.cm.gray or plt.cm.gray_r (reversed). There's a full list of colormaps here: http://matplotlib.org/examples/pylab_examples/show_colormaps.html

Categories : Python

Finding a different sort of connected component
A maximal uni-connected subgraph (I refuse to call them "components", because the underlying relation is not transitive) contains all or none of a strongly connected component. As a first step in enumerating maximal uni-connected subgraphs, then, collapse each SCC to a single vertex (i.e., compute the condensation of the input graph). A uni-connected subgraph of an acyclic directed graph has the property that, for distinct nodes u and v, either there is a path from u to v, or a path from v to u, but not both. Write u < v if there is a path from u to v and u != v. Since either u < v or v < u but not both, and u < v and v < w implies u < w, the relation < is a strict total order. By sorting the vertices in the subgraph, we find that they lie on a single path. This path

Categories : Algorithm

How to find the complexity of a program to find the length of the largest sub string?
You have two nested loops of order n (where n is the length of string), so is O(n*n) = O(n2). There are some other operations which are not important in calculating big O, e.g Split, takes O(n), but compare to O(n2) is not important, or push and pop, ... in each for loop takes O(1), but it's not important if we have multiple O(1) operations. For elaboration: We know that the first loop runs n times, but about the second loop, it will run O(n-i) time, so total running time is: Σ(n-i) = Σ n - Σ i = n2 - n(n-1)/2 = O(n^2).

Categories : Algorithm

change navigator.notification.confirm Background color (White to Black)
I guess we can not change the background and text as it is the default for specific platforms. Like for Android it is looking like this and for iOS it will look different. So to make customize alert box you can use jAlert or jquery mobile popup. http://www.smooka.com/blog/2009/02/22/jalert-jquery-alert-box-plugin/ http://jquerymobile.com/demos/1.2.0/docs/pages/popup/

Categories : Javascript

Modify jQuery UI colorpicker slider to include black and white values
Figured it out: $("#slider-horiz").slider({ orientation: "horizontal", min: 0, max: 360, value: 0, slide: function (event, ui) { box.style.background = 'hsl(' + ui.value + ', 100%, 50%)'; var clr = $('#box').css('background-color'); $('#box').attr('data-color', clr).trigger('click'); if (ui.value == 0) { $('#box').attr('data-color', 'hsl(' + ui.value + ', 0%, 0%)').trigger('click'); $('#slider-handle').css('background-color', '#000'); } if (ui.value == 360) { $('#box').attr('data-color', 'hsl(' + ui.value + ', 100%, 100%)').trigger('click'); $('#slider-handle').css('background-color', '#fff'); } } }); });

Categories : Jquery

Connected component labelling Vs Blob detection Vs Contours
I think, connected components and blobs are synonyms. Contours are the different thing. A contour is a line that represents a sudden color change in an image. A connected component is a set of adjacent pixels of the same color. In relation to OpenCV, it currently doesn't have any component labeling and blob detection (probably, because it's a trivial thing). However, it has a few methods for contour detection. So do not confuse contours with connected components.

Categories : Opencv

AxWindowsMediaPlayer - black component when starts to play movie
private void OnPlayStateChange(object sender, AxWMPLib._WMPOCXEvents_PlayStateChangeEvent e) { switch (e.newState) { case 3: // Playing started // Show your control break; } }

Categories : C#

How to find composite component in JSF component tree?
The UIComponent class has a isCompositeComponent() helper method for exactly this purpose. So, this should just do: for (UIComponent child : component.getChildren()) { if (UIComponent.isCompositeComponent(child)) { // It's a composite child! } } For the interested in "under the covers" workings, here's the implementation source code from Mojarra 2.1.25: public static boolean isCompositeComponent(UIComponent component) { if (component == null) { throw new NullPointerException(); } boolean result = false; if (null != component.isCompositeComponent) { result = component.isCompositeComponent.booleanValue(); } else { result = component.isCompositeComponent = (component.getAttributes().containsKey(

Categories : JSF

Find the Kth largest int in array
the < and > in your code is reverse in partition() as @Dietmar Kühl mentioned,by change them,it works correctly. besides,my suggestion is to use a normal partition() of quicksort as follow, for whose two index of which move in the same direction and one of them never surpasses another. It is not easy to make anyone confused. int partition(int *input, int p, int r) { int pivot,i,j,tmp; pivot = input[r]; i = p-1; for (j=p;j<=r-1;j++) { if (input[j]>= pivot) { i++; tmp = input[i]; input[i] = input[j]; input[j] = tmp; } } tmp = input[i+1]; input[i+1] = input[r]; input[r] = tmp; return i+1; }

Categories : C++

How to find pair with kth largest sum?
I start with a simple but not quite linear-time algorithm. We choose some value between array1[0]+array2[0] and array1[N-1]+array2[N-1]. Then we determine how many pair sums are greater than this value and how many of them are less. This may be done by iterating the arrays with two pointers: pointer to the first array incremented when sum is too large and pointer to the second array decremented when sum is too small. Repeating this procedure for different values and using binary search (or one-sided binary search) we could find Kth largest sum in O(N log R) time, where N is size of the largest array and R is number of possible values between array1[N-1]+array2[N-1] and array1[0]+array2[0]. This algorithm has linear time complexity only when the array elements are integers bounded by small

Categories : Performance

How to find largest values in C++ Map
I doubt there's a "Textbook Answer", and the answer is no: you can't sort maps by value. You could always create another map using the values. However, this is not the most efficient solution. What I think would be better is for you to chuck the values into a priority_queue, and then pop the first 100 off. Note that you don't need to store the words in the second data structure. You can store pointers or references to the word, or even a map::iterator. Now, there's another approach you could consider. That is to maintain a running order of the top 100 candidates as you build your first map. That way there would be no need to do the second pass and build an extra structure which, as you pointed out, is wasteful. To do this efficiently you would probably use a heap-like approach and

Categories : C++

For double f, float g, How to find largest int i, such that i*g <= f
I think you should try to fix the root problem (.1f too far away from .1), i.e. turn TILE_SIZE into a double, or use floats consistently everywhere. Otherwise you might get similar problems caused by minimal rounding errors throughout the code. The candidate_answer function is a hack to work around a problem that should not exist in the first place. P.S. For this particular problem, you might just want to find a formula that is more robust, i.e. isn't sensitive to minimal rounding errors in one direction only. Try to put the player in the center of its field instead of at the tile edge where it can easily fall into rounding errors: col = (int)((x + MINIMAL_STEP_SIZE / 2.0) / TILE_SIZE) (Ideally, the MINIMAL_STEP_SIZE/2 part would already be part of x instead of being added here)

Categories : Java

Find largest intersecting diagonals
There is no asymptotic better solution with regards to time complexity. A weaker problem is to check if the matrix contains any 1-cell. For this problem you clearly you have to visit every cell, which gives you O(nxm). Now this is a lower bound to the original problem, which also has O(nxm). Qed.

Categories : Algorithm

How to find the largest power of 2 less than the given number
Change res =(int)Math.pow(res, 2); to res *= 2; This will return the next power of 2 greater than res. The final result you are looking for will therefore finally be res / 2 after the while has ended. To prevent the code from overflowing the int value space you should/could change the type of res to double/long, anything that can hold higher values than int. In the end you would have to cast one time.

Categories : Java

How to find largest delta in array?
change int[] largestDelta = {0}; to int largestDelta = stocks[0]; or int largestDelta = 0; Also remember about changing the return type.

Categories : Java

Splash screen displays white screen and then black before it sets the menu page
Is your Code for doing background things running in another thread or is it part of the UI Thread? Because your animation wont be shown until your onCreate method finishes, so that could be. Also you could use startAnimation(animation) on the imageviews so they start in that moment.

Categories : Android

Find the largest integer in Datagridview column Vb.net
Try this Dim abcd as Integer For x As Integer = 0 to Datagrid.Rows.Count - 1 If abcd = 0 then abcd = Datagrid.Rows(x).Cells(0).Value Else if abcd < Datagrid.Rows(x).Cells(0).Value Then abcd = Datagrid.Rows(x).Cells(0).Value Endif Next MsgBox(abcd)

Categories : Vb.Net

How to find largest number in an array using NASM
The output 2222 is correct for a 32 bit register. Each number is 8 bits, 4 numbers = 8 * 4 = 32, the max a 32 bit register can hold. This is why if you change to 64 bit registers, the full number is printed. You will need to change the displayed number into a string to display the full number.

Categories : Arrays

How to find the size of the largest file in a directory?
Java 7 offers the new java.nio.* classes including a FileVisitor: http://docs.oracle.com/javase/tutorial/essential/io/walk.html I used them already, but i cant say, which solution is the better one. In my opinion you should keep your solution, because it is better to read.

Categories : Java

Find largest document size in MongoDB
You can use a small shell script to get this value. Note : Following will do a full table scan var max = 0; db.test.find().forEach(function(obj) { var curr = Object.bsonsize(obj); if(max < curr) { max = curr; } }) print(max);

Categories : Mongodb

How to find the k largest integers in a list in O(n) time?
One easy way to do this is by turning the list into a heap and popping k times. In Python, this can be done with the heapq module. import heapq numbers = [6,1,32,8,2,1,9,77,12,-643,-6,3] def getKLargest(nums, k): nums = [-x for x in nums] heapq.heapify(nums) for _ in xrange(k): yield -heapq.heappop(nums) print list(getKLargest(numbers, 5)) print sorted(numbers, reverse=True)[:5]

Categories : List



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