logo
down
shadow

What is the best approach for isolating a single area of similar colour?


What is the best approach for isolating a single area of similar colour?

By : user3042995
Date : November 29 2020, 12:01 PM
may help you . Your dark value becomes 16/13/32 in HSV. And your light value becomes 23/14/60 in HSV.
OpenCV scales the Hue values by dividing by 2 so that the full range of 360 becomes 180 and still fits into an unsigned 8-bit number. So, you need to use a dark Hue value of 8 and a light Hue value of 12. I would widen that range by 3-5 at each end to allow some leeway, and use a lowish saturation to only pick up unsaturated, greyish values. So the code becomes:
code :
#!/usr/bin/env python3

import cv2
import numpy as np

img = cv2.imread("static.jpg")
img_hsv = cv2.cvtColor(img, cv2.COLOR_BGR2HSV)

# light color in RGB = [153, 139, 130]
# dark color in RGB = [82, 74, 71]

hsv_lo = np.array([5,0,0])
hsv_hi = np.array([15,50,255])
mask = cv2.inRange(img_hsv, hsv_lo, hsv_hi)
res = cv2.bitwise_and(img, img, mask = mask)
cv2.imwrite("result.png", res)


Share : facebook icon twitter icon
How would you approach isolating a dependency resolver to one area in MVC3?

How would you approach isolating a dependency resolver to one area in MVC3?


By : Gal
Date : March 29 2020, 07:55 AM
With these it helps IDependencyResolver is global by design. If you want to vary behavior by area, you should look at the various *Activator types and interfaces that can make decisions based on context objects.
What specifically are you trying to do?
Producing an area chart in D3 similar to Highcharts Basic Area

Producing an area chart in D3 similar to Highcharts Basic Area


By : RajK
Date : March 29 2020, 07:55 AM
it fixes the issue Usually when one creates an areas chart each area start where the previous area ended (that taking in consideration that one area "starts" from the bottom). But you want to make it starts not from the end of another area but from the x-axis, right?
Ok, a couple of tips for achieving this:
code :
d3.select('svg g')
.selectAll('path.area')
.data(areas)
.enter()
.insert('path','path.area:first-child')
.attr('class','area')
.attr('d', function(d,i) {
    return yourAreaFunction(d,i);
})
.each(function(d,i) {
    d3.select(this)
    .style('fill', yourFillFunction(d,i))
    .style('opacity', function() {
        return ((1 / areas.length) * (i + 1));
    })
});
How to fill area with our choice colour in plotly area grap

How to fill area with our choice colour in plotly area grap


By : Ratoavelo Ratoavelo
Date : March 29 2020, 07:55 AM
I wish this helpful for you Just add fillcolor to your data.
code :
var trace1 = {
  x: ['Nov 2013', 'Dec 2013', 'Jan 2014', 'Feb 2014'],
  y: [2, 1, 3, 5],
  fill: 'tozeroy',
  type: 'scatter',
  fillcolor: 'red'
};

var data = [trace1];

Plotly.newPlot('myDiv', data);
<script src="https://cdn.plot.ly/plotly-latest.min.js"></script>
<div id='myDiv'></div>
Find the overlapping area of two imageviews overlap, and make this area change colour

Find the overlapping area of two imageviews overlap, and make this area change colour


By : nodejs_enthusiastic
Date : March 29 2020, 07:55 AM
help you fix your problem so I figured out a way to do this mathematically! Basically you use basic trigonometry to find the angles required for the two "arcs" of the intersection, and make a Bezier Path composed of these two arcs. Then just superpose the bezier path and you're done! Here's my code if anyone is interested :)
Note: this assumes both circles have the same radius, and I have clipped my imageviews such that they are circular!
code :
let circlePath = UIBezierPath()
let left_circle_center = left_image_view.center.x
let right_circle_center = right_image_view.center.x
let radius = left_image_view.frame.width/2
let angle = acos( (left_circle_center - right_circle_center)/radius) 
intersection_Path.addArc(withCenter: right_circle_center, radius: radius, startAngle: CGFloat(Double.pi-angle), endAngle: CGFloat(Double.pi+angle), clockwise: true)
intersection_Path.addArc(withCenter: left_circle_center, radius: radius, startAngle: CGFloat(-angle), endAngle: CGFloat(angle), clockwise: true               
let intersection_area = CAShapeLayer()
intersection_area.path = intersection_Path.cgPath
intersection_area.borderColor = ...
intersection_area.strokeColor = ...
intersection_area.fillColor = ...
self.view.layer.addSublayer(intersection_area)
Fill randomly shaped area of single colour by clicking on it

Fill randomly shaped area of single colour by clicking on it


By : paralogue
Date : March 29 2020, 07:55 AM
I think the issue was by ths following , After some research, I decided to dig into the source of http://skribbl.io which has a reliable and fast filling tool. They found an iterative solution. I extracted a snippet from the source file and changed parts to make it easier to read:
code :
function DrawingBoard(canvas) {
    this.canvas = canvas;
    this.canvasCtx = this.canvas.getContext("2d");
}

DrawingBoard.prototype.getPixel = function(imageData, x, y) {
    var startIndex = 4 * (y * imageData.width + x);
    return startIndex >= 0 && startIndex < imageData.data.length ? [imageData.data[startIndex], imageData.data[startIndex + 1], imageData.data[startIndex + 2]] : [0, 0, 0]
}

DrawingBoard.prototype.setPixel = function(imageData, startIndex, r, g, b) {
    startIndex >= 0 && startIndex < imageData.data.length && (imageData.data[startIndex] = r, imageData.data[startIndex + 1] = g, imageData.data[startIndex + 2] = b, imageData.data[startIndex + 3] = 255)
}

DrawingBoard.prototype.floodFill = function(startX, startY, r, g, b) {
    var imageData = this.canvasCtx.getImageData(0, 0, this.canvas.width, this.canvas.height), points = [[startX, startY]], targetPixelRGB = this.getPixel(imageData, startX, startY);
    if (r != targetPixelRGB[0] || g != targetPixelRGB[1] || b != targetPixelRGB[2]) {
        for (
            var c = function(t) {
                var e = imageData.data[t],
                    i = imageData.data[t + 1],
                    c = imageData.data[t + 2];
                if (e == r && i == g && c == b) return false;
                var u = Math.abs(e - targetPixelRGB[0]),
                    h = Math.abs(i - targetPixelRGB[1]),
                    l = Math.abs(c - targetPixelRGB[2]);
                return u < 1 && h < 1 && l < 1
            },
            imageHeight = imageData.height, imageHeightWidth = imageData.width; points.length;
        ) {
            var point, pointX, pointY, index, y, m;
            for (point = points.pop(), pointX = point[0], pointY = point[1], index = 4 * (pointY * imageHeightWidth + pointX); pointY-- >= 0 && c(index);) {
                index -= 4 * imageHeightWidth;
            }
            for (index += 4 * imageHeightWidth, ++pointY, y = 0, m = 0; pointY++ < imageHeight - 1 && c(index);) {
                this.setPixel(imageData, index, r, g, b);
                pointX > 0;
                c(index - 4) ? y || (points.push([pointX - 1, pointY]), y = 1) : y && (y = 0);
                pointX < imageHeightWidth - 1;
                c(index + 4) ? m || (points.push([pointX + 1, pointY]), m = 1) : m && (m = 0);
                index += 4 * imageHeightWidth;
            }
        }
        this.canvasCtx.putImageData(imageData, 0, 0)
    }
}

// TEST

var db = new DrawingBoard(document.getElementById('can'));
var img = new Image();
var fillColor = [255, 0, 255];
img.onload = (function() {
    db.canvasCtx.drawImage(this, 0, 0);
}).bind(img);
img.src = 'test.png';

addEventListener('click', function(e) {
    var cx = e.clientX, cy = e.clientY;

    if(
        e.button === 0 &&
        cx > 0 && cx < db.canvas.width &&
        cy > 0 && cy < db.canvas.height
    ) {
        db.floodFill(cx, cy, fillColor[0], fillColor[1], fillColor[2]);
    }
}, false);
body {
  padding: 0;
  margin: 0;
}
<canvas id="can" width="600" height="400"></canvas>
Related Posts Related Posts :
  • Tuning the hyperparameter with gridsearch results in overfitting
  • some coordinates that I extracted from geocoder in Python are not saving in the variable I created
  • 7C in cs circles- python Im not sure what is wrong with this yet
  • How to fix 'AttributeError: 'list' object has no attribute 'shape'' error in python with Tensorflow / Keras when loading
  • python - thread`s target is a method of an object
  • Retrieve Variable From Class
  • What is the reason for matplotlib for printing labels multiple times?
  • Why would people use ThreadPoolExecutor instead of direct function call?
  • When clear_widgets is called, it doesnt remove screens in ScreenManager
  • Python can't import function
  • Pieces doesn't stack after one loop on my connect4
  • How to change font size of all .docx document with python-docx
  • How to store a word with # in .cfg file
  • How to append dictionaries to a dictionary?
  • How can I scrape text within paragraph tag with some other tags then within the paragraph text?
  • Custom entity ruler with SpaCy did not return a match
  • Logging with two handlers - one to file and one to stderr
  • How to do pivot_table in dask with aggfunc 'min'?
  • This for loop displays only the last entry of the student record
  • How to split a string by a specific pattern in number of characters?
  • Python 3: how to scrape research results from a website using CSFR?
  • Setting the scoring parameter of RandomizedSeachCV to r2
  • How to send alert or message from view.py to template?
  • How to add qml ScatterSeries to existing qml defined ChartView?
  • Django + tox: Apps aren't loaded yet
  • My css and images arent showing in django
  • Probability mass function sum 2 dice roll?
  • Cannot call ubuntu 'ulimit' from python subprocess without using shell option
  • Dataframe Timestamp Filter for new/repeating value
  • Problem with clicking select2 dropdownlist in selenium
  • pandas dataframe masks to write values into new column
  • How to click on item in navigation bar on top of page using selenium python?
  • Add multiple EntityRuler with spaCy (ValueError: 'entity_ruler' already exists in pipeline)
  • error when replacing missing ')' using negative look ahead regex in python
  • Is there a way to remove specific strings from indexes using a for loop?
  • select multiple tags by position in beautifulSoup
  • pytest: getting AttributeError: 'CaptureFixture' object has no attribute 'readouterror' capturing stdout
  • Shipping PyGObject/GTK+ app on Windows with MingW
  • Python script to deduplicate lines in multiple files
  • How to prevent window and widgets in a pyqt5 application from changing size when the visibility of one widget is altered
  • How to draw stacked bar plot from df.groupby('feature')['label'].value_counts()
  • Python subprocess doesn't work without sleep
  • How can I adjust 'the time' in python with module Re
  • Join original np array with resulting np array in a form of dictionary? multidimensional array? etc?
  • Forcing labels on histograms in each individual graph in a figure
  • For an infinite dataset, is the data used in each epoch the same?
  • Is there a more efficent way to extend a string?
  • Is it possible to do this loop in a one-liner?
  • invalid literal for int() with base 10: - django
  • Why does my code print a value that I have not assigned as yet?
  • the collatz func in automate boring stuff with python
  • How to find all possible combinations of parameters and funtions
  • about backpropagation deep neural network in tensorflow
  • Sort strings in pandas
  • How do access my flask app hosted in docker?
  • Replace the sentence include some text with Python regex
  • Counting the most common element in a 2D List in Python
  • logout a user from the system using a function in python
  • mp4 metadata not found but exists
  • Django: QuerySet with ExpressionWrapper
  • shadow
    Privacy Policy - Terms - Contact Us © festivalmusicasacra.org