投稿時間:2023-03-19 05:14:28 RSSフィード2023-03-19 05:00 分まとめ(19件)

カテゴリー等 サイト名等 記事タイトル・トレンドワード等 リンクURL 頻出ワード・要約等/検索ボリューム 登録日
海外TECH MakeUseOf How To Activate Windows 11 With a Windows 7 Key https://www.makeuseof.com/activate-windows-11-windows-7-key/ windows 2023-03-18 19:16:16
海外TECH DEV Community Writing a Multithreaded Image Dithering Program with Rust 🦀🖼️ https://dev.to/nabeelahmed1721/writing-a-multithreaded-image-dithering-program-with-rust-369 Writing a Multithreaded Image Dithering Program with Rust ️Check out the project here I have been interested in the Rust programming language for the past couple of months Coming from JavaScript a weakly typed language I find that Rust is much more strict and requires more thought when developing a control flow Just for the record dithering isn t usually done on the CPU It s a task best suited for a GPU where it can take advantage of parallelism I used this project as a way to learn about Rust and multithreading If you want a guide for dithering done on a GPU take a look at this OverviewSimply put dithering is the process of adding noise to quantized data To understand quantized data think about omitting information needed to represent some data for example using less color to express an image It s important to note that dithering is a general term in information processing With its use stretching far into audio radar weather and many other applications it isn t limited to images There are several image dithering techniques my project uses Ordered or Bayer Dithering Is it the most practical Probably not But if you ask me I think it visually looks the most interesting Anyway before we dive into the project itself here are some results to entice you to continue reading Dithered Image of Apple bit color Dithered Image of Sunlight through Leaves bit color Dithered Image of Lava bit color Ordered DitheringTo dither an image using ordered dithering we must compare every pixel in the source image with an input palette and a threshold matrix commonly referred as Bayer Matrix or Filter For the sake of consistency our project will use an bit color palette which includes the following colors const PALETTE Color Color black Color red Color green Color blue Color yellow Color magenta Color cyan Color white You are free to use any assortment of colors however I find that the bit color range has a reliable balance of colors that works for most images To generate a threshold matrix we can use the following recursion formula to create a Bayer Matrix to the nnn th level Bayer n ⋅Bayer n ⋅Bayer n ⋅Bayer n ⋅Bayer n Bayer n begin bmatrix cdot Bayer n amp cdot Bayer n cdot Bayer n amp cdot Bayer n end bmatrix Bayer n ⋅Bayer n ⋅Bayer n ​⋅Bayer n ⋅Bayer n ​ where for every nnn th level the matrix is n ×n n times n n ×n and contains numbers from to n n n Full credit of this equation and a special thanks goes to this wonderful article by Surma In practice however this type of computation quickly becomes expensive to generate during runtime so it s more reasonable to reference from a pre generated matrix Hence why my program uses a pre generated × times × threshold matrix which looks like the following begin bmatrix amp amp amp amp amp amp amp amp amp amp amp amp amp amp amp amp amp amp amp amp amp amp amp amp amp amp amp amp amp amp amp amp amp amp amp amp amp amp amp amp amp amp amp amp amp amp amp amp amp amp amp amp amp amp amp amp end bmatrix ⎣⎡​​​​​​​​​⎦⎤​The differences in matrix sizes reflect the complexity of the dithering pattern on the output image A small × times × matrix produces an output with striking contrast and a rugged dithering pattern While a larger × times × matrix results in smoother contrast with a granular dithering pattern However there are diminishing returns with larger matrix sizesーI find that an × times × matrix works best to smooth colors but also maintain that pixelated dithered look To reduce complexity I express the matrix as a D array and through the calculations below I can convert the x y coordinates of the image to a value I can use to index the array x Bayer Matrixconst MATRIX WIDTH u const MATRIX u fn get bayer x u y u gt u let pos x MATRIX WIDTH y MATRIX WIDTH MATRIX WIDTH MATRIX WIDTH MATRIX pos as usize We need to however map the threshold value from n n n to because the RGB color values of the input image will be between and To solve this I used a simple range mapping formula pub fn map range value value u range in u u range out u u gt u return value range in range out range out range in range in range out Combining what we know we can calculate our threshold value for a given pixel at an x y coordinate with the following expression let bay utility map range value Dither get bayer x y To calculate the quantized value of a given pixel color we multiply the bay value with a spread value The product is then summed with the input color which is adjusted by a gamma value let quantize value c u gt u f min f powf f from c self gamma self spread f from bay as u let query color Color quantize value r quantize value g quantize value b Finally we use query color to search for the closest match in the defined palette The closest color match is then set as the pixel value at the given x y coordinate on the output image Repeating this process for every pixel in an input image will result in an dithered output image MultithreadingSince the dithering process itself can run on each pixel independently in other words an individual pixel doesn t need to know the state of another pixel this creates an ideal opportunity for multithreading Fortunately because of Rust s borrow checker multithreading is simple and intuitive Common bugs such as data races locks and memory leaks are harder to encounter Depending on the application multithreading can get hard to manage I find it helpful to visualize the control flow to prevent confusion when programming The following is how I expect my program to run Dividing the image into separate even chunks allows for a convenient collection process Since each thread is assigned an ID we can use the following formulas to calculate the starting and ending locations of each chuck let thread location start area self thread count thread id let mut thread location end area self thread count thread id looping through specific chunkfor i in thread location start thread location end dithering logic To identify and manage threads I created separate helper module called worker Within the module a struct called Manager stores all threads individually called Worker in a vec and executes a collect method when threads complete Overall this allowed me to abstract multithreading logic and keep my code more manageable let mut manager worker Manager lt DitherJob gt new THREAD COUNT let worker count manager worker count let dither Arc new Dither new worker count reference image amp PALETTE GAMMA SPREAD manager set workers amp id let dither Arc clone amp dither thread spawn move dither dither section id manager collect amp mut output Notice how Dither is wrapped Arc new To safely share ownership of data across threads an Atomic Reference Counter Arc needs to be used It keeps count of the owners and drops the value when no threads are using it ConclusionOverall I m pleased with how the program turned out With me still learning Rust this project has helped me to become more confident in using the language and allowed me to explore new ideas in image processing I hope you enjoyed reading my article and again feel free to check out the project below Thank you Nabeel Ahmed 2023-03-18 19:23:37
海外TECH DEV Community DALL-E with node.js https://dev.to/djibrilm/dall-e-with-nodejs-5chb DALL E with node jsIntroductionover the last few years we have seen how machine learning and artificial intelligence have improved a lot and now we are seeing how artificial intelligence is affecting our daily routines and how we interact with the internet From high level chatbots to incredible images generators but among those technologies the one I am excited about the most is the possibility of generating images and art through thought and imagination and this article we shall see how to generate images from inputs also called prompt using DALL E model please note that DALL E is not free after creating your account you will receive free credits that are enough for our min application and testing purposes Create accountBefore start building our application we shall start by creating our account and generating an API token that we shall use to access the networkuse the following link to create your account if you don t have one yet after creating your account click on your profile s image and go to view API keys once there you will be prompted to create an API key create one here is how the screen looks like Create a simple node js applicationwith all the credentials and information we need for sending our request let us now create our mini node js application and create some simple images initialize a node js application with npm init then install the above dependencies npm install express nodemon openai body parserwe shall be using nodemon for reloading our server when we make changes instead of restarting our application for some small updates For enabling nodemon go to your package json file and add the following script start nodemon index js don t forget to replace the index js with your main entry file create your first image with DALL Econst express require express const app express const openai require openai const bodyparser require body parser body parserapp use bodyparser json app post createImage async req res next gt try const prompt req body prompt const config new openai Configuration apiKey your API key const openaiApi new openai OpenAIApi config const createImage await openaiApi createImage prompt prompt n size x return res status json imageUrl createImage data data url catch error return res status json message internal server error app listen gt console log server started on port let us break down the meaning of that code the n field represents the number of images that we request it goes from to and the prompt fieldis the text used for creating our image it can be anything like a cat playing on play station please note that not all the sizes are supported here is the list x x x Create image variationYou may also want to create variations of your existing image which is also possible with DALL E please note that your image must respect the following requirements must be a png imagemust be square must have less than mbsconst express require express const app express const openai require openai const bodyparser require body parser const path require path const fs require fs body parserapp use bodyparser json app post createVariation async req res next gt const config new openai Configuration apiKey your API key const openaiApi new openai OpenAIApi config const image path join dirname image png const file fs createReadStream image try const createVariation await openaiApi createImageVariation file x const result createVariation data data return res status json imageUrl result catch error console log error message return res status json message error message error error app listen gt console log server started on port In the example above we create two variations of one image which means our response will be an array Please make sure your image is a square and a valid PNG otherwise this will not work anymore Bonusgenerating images and creating variations is very amazing and full of fun but what if you want to take the image provided on the URL and write it to your local storage or the storage where your server is running the following functionality does not have anything in relation with openai library this function if fully implemented with nod js build in functions this process may take unexpected amount of time since generated images are a bit heavy const result your image URL const fetchFile await fetch result const responseBlob await fetchFile blob const arrayBuffer await responseBlob arrayBuffer const buffer Buffer from arrayBuffer const filePath path join dirname new Date png const writeFileToDisc fs writeFileSync filePath buffer For this example i use the current date for naming files in a unique fashion please feel free to use any method of your choice conclusion Generating images with DALL E is very amazing and satisfying but there is another amazing API much more epic and much more creative if this article reaches more than likes I promise to write another article on how to interact with MID JOURNEY something that you will like if you liked this article don t forget to show some love by liking and following for more contents 2023-03-18 19:04:03
ニュース BBC News - Home Match of the Day: 'Great to be here', says Lineker as he makes TV return https://www.bbc.co.uk/news/uk-65003113?at_medium=RSS&at_campaign=KARANGA impartiality 2023-03-18 19:01:16
ニュース BBC News - Home Six Nations 2023: Ireland 29-16 England - Irish seal Grand Slam in Dublin https://www.bbc.co.uk/sport/rugby-union/64992479?at_medium=RSS&at_campaign=KARANGA dublin 2023-03-18 19:50:46
ニュース BBC News - Home Antonio Conte criticises Tottenham Hotspur ownership and 'selfish' players https://www.bbc.co.uk/sport/football/65002960?at_medium=RSS&at_campaign=KARANGA Antonio Conte criticises Tottenham Hotspur ownership and x selfish x playersA furious Antonio Conte says his Tottenham players are selfish and the club can change the manager but the situation cannot change 2023-03-18 19:27:00
ニュース BBC News - Home Six Nations 2023: Freddie Steward's red card against Ireland called 'an utter farce' https://www.bbc.co.uk/sport/rugby-union/65002154?at_medium=RSS&at_campaign=KARANGA Six Nations Freddie Steward x s red card against Ireland called x an utter farce x A red card given to England full back Freddie Steward in Saturday s defeat by Grand Slam winners Ireland has been called an utter farce and absolutely ridiculous by former players 2023-03-18 19:35:32
ビジネス ダイヤモンド・オンライン - 新着記事 経済学者シュンペーターを日本に初めて知らしめたのは「意外な文豪」だった - ビジネスを強くする教養 https://diamond.jp/articles/-/319594 経済学者シュンペーターを日本に初めて知らしめたのは「意外な文豪」だったビジネスを強くする教養年は「現代史上の大経済学者」、マルクス没後年、ケインズとシュンペーターの生誕年という節目の年に当たる。 2023-03-19 05:00:00
ビジネス ダイヤモンド・オンライン - 新着記事 三菱ケミカルが事業も人も切りまくり!「世界のタケダ」化が進む【見逃し配信】 - 見逃し配信 https://diamond.jp/articles/-/319723 三菱ケミカル 2023-03-19 04:50:00
ビジネス ダイヤモンド・オンライン - 新着記事 6000軒を片づけた家政婦が教える「思い出の品」をうまく整理できる方法 - タスカジ最強家政婦seaさんの人生が楽しくなる整理収納術 https://diamond.jp/articles/-/319538 迷走 2023-03-19 04:45:00
ビジネス ダイヤモンド・オンライン - 新着記事 月収「数百万円」の猛者も、無料の“Twitter漫画”がクリエイターに人気の訳 - ニュース3面鏡 https://diamond.jp/articles/-/318243 月収「数百万円」の猛者も、無料の“Twitter漫画がクリエイターに人気の訳ニュース面鏡サクッと読める「Twitter漫画」が人気だ。 2023-03-19 04:40:00
ビジネス ダイヤモンド・オンライン - 新着記事 日本一道路が広い政令都市は、名古屋市?それとも…!? - 日本の道・道路がわかる雑学 https://diamond.jp/articles/-/319119 名古屋市 2023-03-19 04:35:00
ビジネス ダイヤモンド・オンライン - 新着記事 オンライン会議では長くやっても結論が出ない理由【スマホはどこまで脳を壊すか】 - from AERAdot. https://diamond.jp/articles/-/319648 オンライン会議では長くやっても結論が出ない理由【スマホはどこまで脳を壊すか】fromAERAdotコロナ禍をきっかけに一気に進んだ「オンライン化」。 2023-03-19 04:30:00
ビジネス ダイヤモンド・オンライン - 新着記事 ダイエット中の「今日だけ食欲解放」チートデイは有効?有害?専門家に聞く - 男のオフビジネス https://diamond.jp/articles/-/319620 cheatday 2023-03-19 04:25:00
ビジネス ダイヤモンド・オンライン - 新着記事 ハリー・ポッターのラッピング電車が東京に登場!池袋~としまえん跡地を駆け抜ける! - 地球の歩き方ニュース&レポート https://diamond.jp/articles/-/319551 地球の歩き方 2023-03-19 04:20:00
ビジネス ダイヤモンド・オンライン - 新着記事 新日本酒紀行「饗之光」 - 新日本酒紀行 https://diamond.jp/articles/-/319412 有機農家 2023-03-19 04:15:00
ビジネス ダイヤモンド・オンライン - 新着記事 アルツハイマー治療薬「メマンチン」が、抜毛症や皮膚むしり症の軽減に役立つ可能性 - ヘルスデーニュース https://diamond.jp/articles/-/319726 臨床試験 2023-03-19 04:10:00
ビジネス 東洋経済オンライン 「30年待った」台湾“山あり谷あり"LRT新線の効果 山間部新興住宅地の足、本領発揮はまだまだ先? | 海外 | 東洋経済オンライン https://toyokeizai.net/articles/-/659454?utm_source=rss&utm_medium=http&utm_campaign=link_back quotlrt 2023-03-19 04:30:00
海外TECH reddit Post match thread: Ireland v England https://www.reddit.com/r/rugbyunion/comments/11uwt3j/post_match_thread_ireland_v_england/ Post match thread Ireland v EnglandIreland England submitted by u confused ninja to r rugbyunion link comments 2023-03-18 19:01:10

コメント

このブログの人気の投稿

投稿時間:2021-06-17 05:05:34 RSSフィード2021-06-17 05:00 分まとめ(1274件)

投稿時間:2021-06-20 02:06:12 RSSフィード2021-06-20 02:00 分まとめ(3871件)

投稿時間:2020-12-01 09:41:49 RSSフィード2020-12-01 09:00 分まとめ(69件)