algorithms – Filling a hole in an image in O(nlogn)

I have a grayscale image (given by a float matrix with values between (0, 1)) with a hole in it (a cluster of pixels/cells with values of -1).

Definitions:

The boundary of the hole as all the cells that are 4-connected to a hole pixel (a pixel with -1 value) (you can read more about pixel connectivity here: https://en.wikipedia.org/wiki/Pixel_connectivity).

I(v) is the color of the pixel v.

I need the fill the hole using this formula:

Denote the boundary with B. So for each u – hole pixel:

begin{equation}
I(u) = frac{Sigma_v{_in}_B w(u,v) * I(v))}{Sigma_v{_in}_B w(u,v)}
end{equation}

Where w is some arbitrary weighting function (for example using euclidean distance)

begin{equation}
w(v,u) = frac{1}{|| u – v||}
end{equation}

Denote the number of hole pixels with n, the naive solution will be O(n^2), since for each hole pixel, we sum over all boundary pixels (and the upper bound for the amount of boundary pixels is 4n, of course).

I was told a solution could be achieved in O(nlogn), but I couldn’t think of anything even close to that.

I thought of doing some bitwise operations, but I reached a dead end. I also tried reusing computations, but I couldn’t find any.

Moreover, the way I see it, there’s no avoiding calculating w(u,v) for the n^2 pairs of hole/boundary pixels – which is already more than O(nlogn).

What am I missing? Could you point me at the right direction?

Thanks

Old Windows Wallpaper Image ‘shedinfield1024’ – Can anyone tell me where this photo was taken?

enter image description here
This is a photograph of an old farm building in a valley amongst wooded mountains. In the distance the roof of a white house with a red tile roof is visible.

upload image error "An Ajax http request terminated abnormally.." on Google Chrome [closed]

My website i use Drupal 7.69

I use Google Chrome Version 83.0.4103.61 (Official Build) (64-bit)

when upload image it’s show

https://ibb.co/wR0wVr0

And click “Remove”

https://ibb.co/M9rj222

But i use Safari not have error.

javascript – I can’t clear the paint image in my Canvas

I’m trying to make the Mario move, but somehow it leaves traces behind, can anybody help???

var canvas = document.getElementById("screen");
var ctx = canvas.getContext("2d");
var mario;
var marioSprite;
var tiles;
var speedX = 1;

//marioSprite Specification
mario = {
    //target picture specification X & Y, Width & Height
    px:276,
    py: 44,
    pwidth: 16,
    pheight: 16,
    //drawing on Canvas specification X & Y, Width & Height
    cx: 16,
    cy: 116,
    cwidth:16,
    cheight:16,
}


//draw Mario in Canvas
function drawMarioSprite(){
    marioSprite = new Image();
    marioSprite.src = "https://gamedev.stackexchange.com/file:///C:/Users/MASTONO ALI/Desktop/img/characters.gif";
    marioSprite.addEventListener('load', e => {
    ctx.drawImage(marioSprite, 
        mario.px, mario.py, mario.pwidth, mario.pheight, 
        mario.cx, mario.cy, mario.cwidth, mario.cheight);
    });
    this.position = function() {
        this.mario.cx += speedX;       
    }
    position();
}//drawMarioSprite() end

//drawTiles and tilesLoop
function drawTiles() {
    tiles = new Image();
    tiles.src = 'file:///C:/Users/MASTONO ALI/Desktop/img/tiles.png';
    tiles.addEventListener('load', e => {
        tilesLoop();
    });
}
function tilesLoop(){
    for (let x = 0; x < 25; x++){
        for (let y = 11; y < 13; y++){
            ctx.drawImage(tiles, 
                0, 0, 26, 26, 
                x*12, y*12, 20, 20);
        }
    }
}//drawTiles() end


function draw(){

    drawMarioSprite();
    drawTiles();
    window.requestAnimationFrame(draw);
}

window.requestAnimationFrame(draw);

thank you

windows – How do you create a batch file that creates a new folder and names that new folder after an image in the current folder?

ok this sounds confusing but. I want a script that creates a new folder and makes that new folder named after an image in the current folder.
The code that I have so far is “md test” which only creates a new folder and names it test. But I don’t know how to rename it to an image on the current folder.

thanks

A simple way to add a background image to content region

i tried yet the background image moudule but it give me various issues.

There is a really simple way to add a background image to all the website on the content region?

The theme is Bartik.

Thanks in advance.

theming – How to get BOOLEAN value of a Media Image in node.html.twig?

I was able to get the URL of the verctor_graphics reference media field with the following code:

file_url(node.field_vector_graphics(0).entity.field_media_image.entity.fileuri)

But how can I get the boolean media field value (machine name: is_animated)?

led lighting – Camera’s IR Filter for monochrome grayscale image sensor

We are looking for an efficient camera to use for our machine learning application (body tracking and emotion detection). Through my readings, it seems using an IR filter for our camera is quite important. However, most machine learning specialized cameras are grayscale cameras and don’t have IR Filter. We need to add IR LEDs for our camera in order to enable the night vision features.
It seems confusing for me, Am I missing anything or it doesn’t make sense to have IR cut filter and IR LEDs when using a grayscale image sensor? Would you add your thoughts and recommend any useful, and simple articles that explains the same subject?

Regards,

magento2.3 – Add div background image in email template

I have created a custom email template and I want to add background image to one of its div element. I have added html file in my email with below content.

<div
  class="container"
  width="100%"
  style="
    background-image: url('{{view url="My_Module/img/myimage.png"}}');
    padding: 20px 60px;
    background-size: cover;
  "
>

But its not working. It removes whole style tag from my div in final email.
If I am using complete image static url, it works correctly like below.

<div
  class="container"
  width="100%"
  style="
    background-image: url('https://domain.com/my-full-image-path/myimage.png');
    padding: 20px 60px;
    background-size: cover;
  "
>

Please note here that I want to add background image and not img field with src. I have checked and found that the image path is correct so no issues with image path here.
Does anyone know how we can add background image in email template content.

user research – Best Practice for video start image

Personally, I don’t think you should always pick an image from the video. It actually depends on the situation.

I’ve got an example from my recent UX review: a product site with a short video, demonstrating product features, etc.

This video was surrounded with a text, describing the main product idea. And the start image for this video was a random image from the video itself, but, as we all know, picture worth a thousand words, so I suggested to get an refined image describing the main product idea and place it as video start image.

Now we have a text, an illustration for that text and a demo video combined together.

Another example is about an image from the movie itself. There is a local online tv-series streaming service which I use every day. It has a lot of titles, which are grouped by seasons and for every season there is a single page with all episodes. And every episode has a start image taken from the episode itself. It’s okey, until start image is a spoiler image, i.e. something I don’t really expect to see before I watch the epicode by myself!

From the other hand, at YouTube I wish to have a video starting image taking from the video itself so I can decide whatever it’s a right video to watch (there are a lot of music videos with a different video track, etc).

So, it actually depends on the situation.