teferrell Posted August 15, 2013 Share Posted August 15, 2013 I have a method for converting a black and white image into instructions for folding a book into the image (method is here http://www.instructables.com/id/Book-Art-How-to-Fold-a-Book-into-a-Word/). To do this I count filled pixels by column if a zoomed in image. Is there a way to generate a count of filled and unfilled spaces in an image. This would speed up one of the more tedious parts of the process. Thank you for any help. Quote Link to comment Share on other sites More sharing options...
pdnnoob Posted August 15, 2013 Share Posted August 15, 2013 The fastest way I can think of for doing this is to zoom in and select the column with the magic wand tool and look at the info bar at the bottom to see how tall the selection is. Quote No, Paint.NET is not spyware...but, installing it is an IQ test. ~BoltBait Blend modes are like the filling in your sandwich. It's the filling that can change your experience of the sandwich. ~Ego Eram Reputo Link to comment Share on other sites More sharing options...
teferrell Posted August 15, 2013 Author Share Posted August 15, 2013 That is basically what I do, however with over 100 columns it takes a while. I note the beginning and end of the filled (black), or beginning and length. Was hoping for a way to generate the count automatically. Quote Link to comment Share on other sites More sharing options...
TechnoRobbo Posted August 15, 2013 Share Posted August 15, 2013 (edited) Hi, attached is a plugin called PixelCounter - install it as you would any plugin- it will appear under the effects. Create a folder under the C:\ root folder called "count" just lowercase "count" Make your black and white text, hit escape, run PixelCounter (again it's under effects, at the bottom) press ok. look under the C:\count folder and you'll find a file called "pixelcount". open it with Notepad. I've attached an example of the word "Test" The Plugin considers anything that's not white a pixel so you may want to turn off anti-aliasing. Also you can use it to make images in the books. Just a thought. https://www.dropbox.com/s/hp9jep7p2t1408y/pixelcount.txt?dl=0 pixelcounter.zip Edited August 11, 2015 by TechnoRobbo 1 Quote Go out there and be amazing. Have Fun, TRSome Pretty Pictures Some Cool Plugins Link to comment Share on other sites More sharing options...
teferrell Posted August 16, 2013 Author Share Posted August 16, 2013 A million thanks, that is exactly what I needed! Quote Link to comment Share on other sites More sharing options...
TechnoRobbo Posted August 16, 2013 Share Posted August 16, 2013 (edited) cool for any programmer out there curious about the code: Hidden Content: // Name: PixelCounter // Title: PixelCounter #region UICode bool Amount1 = true; // [0,1] #endregion void Render(Surface dst, Surface src, Rectangle rect) { if (Amount1){ Rectangle sel = EnvironmentParameters.GetSelection(src.Bounds).GetBoundsInt(); dst.CopySurface(src, sel.Location,sel); //========================= Amount1=false; try { System.IO.StreamWriter pc = new System.IO.StreamWriter(@"C:/count/pixelcount.txt",false); pc.WriteLine("Begin Count:"); pc.WriteLine(); pc.Close(); for (int x = sel.Left; x< sel.Right; x++){ int toppix=0; int pixlength=0; for (int y= sel.Top; y< sel.Bottom;y++){ ColorBgra CP= src.GetBilinearSample(x,y); int total = CP.R + CP.G + CP.B; if (toppix ==0){ if (total<765){ toppix=y; pixlength=1; } }else{ if (total<765){ pixlength++; }else{ System.IO.StreamWriter pcr = new System.IO.StreamWriter(@"C:/count/pixelcount.txt",true); pcr.WriteLine("Column" + x + " Top=" + toppix + " Length=" + pixlength); pcr.WriteLine(); pcr.Close(); toppix=0; pixlength=0; } } } } System.IO.StreamWriter pce = new System.IO.StreamWriter(@"C:/count/pixelcount.txt",true); pce.WriteLine(":End Count"); pce.WriteLine(); pce.Close(); }catch(Exception e){} }else{ //======= next code is a keep alive for dialog box //so users know its working. ColorBgra CP=dst[0,0]; dst[0,0]=CP; } } Edited August 16, 2013 by TechnoRobbo Quote Go out there and be amazing. Have Fun, TRSome Pretty Pictures Some Cool Plugins Link to comment Share on other sites More sharing options...
heathersharmony Posted November 21, 2013 Share Posted November 21, 2013 I installed the pixelcounter plugin and used it under the effects however when I look in the "count" folder I made in the c:/program files/paintnet folder I cant find the txt file. the count folder is empty. I even ran a search for a pixelcount.txt or anything pixelcount and find nothing. Can you help? Thanks! I am using Windows 7. Quote Link to comment Share on other sites More sharing options...
Ego Eram Reputo Posted November 21, 2013 Share Posted November 21, 2013 You made the folder in the wrong location. You need it to be in this location C:/count/See @TechnoRobbo's post above where he says: Create a folder under the C:\ root folder called "count" just lowercase "count" 1 Quote ebook: Mastering Paint.NET | resources: Plugin Index | Stereogram Tut | proud supporter of Codelab plugins: EER's Plugin Pack | Planetoid | StickMan | WhichSymbol+ | Dr Scott's Markup Renderer | CSV Filetype | dwarf horde plugins: Plugin Browser | ShapeMaker Link to comment Share on other sites More sharing options...
TechnoRobbo Posted November 22, 2013 Share Posted November 22, 2013 Ego is correct. This plugin was written to quickly help teferrell, I found his instructable very fascinating. I didn't flesh it out for general use because I didn't think it would have that many uses. Thanks EER Quote Go out there and be amazing. Have Fun, TRSome Pretty Pictures Some Cool Plugins Link to comment Share on other sites More sharing options...
heathersharmony Posted November 27, 2013 Share Posted November 27, 2013 thanks! Quote Link to comment Share on other sites More sharing options...
heathersharmony Posted November 28, 2013 Share Posted November 28, 2013 got it working...thanks! Now can I ask for help in using it? Sorry to be so tech illiterate. I found the pixel count text and see that it shows the beginning and length in pixels. How do I then understand this in terms of centimeters to use as my word template? Does each pixel stand for a centimeter? Or when the text says column 295 top 456 length 12......top starts at 4.5 cent and is 12 cent long? Quote Link to comment Share on other sites More sharing options...
TechnoRobbo Posted November 28, 2013 Share Posted November 28, 2013 (edited) Gosh I've never folded a book, but from the Instructables by TeFrerrel... http://www.instructables.com/id/Book-Art-How-to-Fold-a-Book-into-a-Word/ I see he uses a scale of 10 per pixel inch (2.53 cm). I'm confused as to how one could use Word since one would have to wrestle with the kerning and justification. Pixel Primer The output file is in pixels (Picture Elements). On a computer graphic pixels are arranged in columns and rows like an Excel spreadsheet cell. Different font sizes achieve a different pixel count. The output file tells you the pixel location in the the terms of how many rows from the top and how many columns from the left margin. The length is how far to the right of that location the pixel extends. I think TeFerrel scales depending on the dimensions of the book (or the number of pages). The word "Love" would require much less pixels for a paperback novel than it would in the monstrous textbook TeFerrel used. My "test" example is only 12 pixels wide. If the book has is 2 inches wide then I assume 6 pixels per inch (2 pixels per cm) or less is appropriate.. Edited November 28, 2013 by TechnoRobbo Quote Go out there and be amazing. Have Fun, TRSome Pretty Pictures Some Cool Plugins Link to comment Share on other sites More sharing options...
heathersharmony Posted January 16, 2014 Share Posted January 16, 2014 The pixel count worked great on my first try but recently when using it there are some problems. around column 40 the count is waaaay off, like 24 pixels longer than it should be. When checking back to the image in paintnet, the image looks correct and I have no idea why it would do this. I am deleting the plugin and reinstalling to see if that helps. Anyone else have this problem? Quote Link to comment Share on other sites More sharing options...
TechnoRobbo Posted January 16, 2014 Share Posted January 16, 2014 if you can post the image maybe I can help Quote Go out there and be amazing. Have Fun, TRSome Pretty Pictures Some Cool Plugins Link to comment Share on other sites More sharing options...
heathersharmony Posted February 13, 2014 Share Posted February 13, 2014 I am hoping someone can pinpoint a problem I am having with the pixelcount plugin. If I have multiple layers it seems to create problems with the count. Also I recently imported an image and after preparing it and running the pixelcount plugin it ignored pixels that were in the lower half of the image. If someone can help with this I can email the pdn file since I can't figure out how to attach it here. Thanks! Quote Link to comment Share on other sites More sharing options...
heathersharmony Posted February 14, 2014 Share Posted February 14, 2014 I am having trouble with the pixelcounter plugin and after posting under the topic "counting filled cells" and not getting responses and asking for help in the facebook group I was advised to post here. Normally when running the plugin after using only text I have no problem however when importing an image (in this case the map of Michigan) the pixelcounter ignored the lower half of the pixels in the image. I am hoping someone might be able to explain why.....maybe the creator of the plugin? I cant upload the pdn file here but I have attached the pixelcount text as well as the original image used. I have also attached an example of the folded books. Thanks! pixelcount michigan.txt Quote Link to comment Share on other sites More sharing options...
Ego Eram Reputo Posted February 15, 2014 Share Posted February 15, 2014 I've merged these threads together to keep this discussion in one place. I'm sure TechnoRobbo will be along shortly to give you some guidance Quote ebook: Mastering Paint.NET | resources: Plugin Index | Stereogram Tut | proud supporter of Codelab plugins: EER's Plugin Pack | Planetoid | StickMan | WhichSymbol+ | Dr Scott's Markup Renderer | CSV Filetype | dwarf horde plugins: Plugin Browser | ShapeMaker Link to comment Share on other sites More sharing options...
TechnoRobbo Posted February 15, 2014 Share Posted February 15, 2014 (edited) I'm sorry I've been extremely busy. I'll have a look. pixelcounter relies on white bordering the image - Go to the image menu - select canvas size, add 2 pixels to the height and width, anchor in the middle and everything will workout fine. Edited August 11, 2015 by TechnoRobbo Quote Go out there and be amazing. Have Fun, TRSome Pretty Pictures Some Cool Plugins Link to comment Share on other sites More sharing options...
heathersharmony Posted February 16, 2014 Share Posted February 16, 2014 Thanks so much! I'll give it a try when I get home from our weekend trip Quote Link to comment Share on other sites More sharing options...
heathersharmony Posted February 17, 2014 Share Posted February 17, 2014 Are you adding the 2 pixels in the Print size area where it shows 1.02 inches and 1.04? Quote Link to comment Share on other sites More sharing options...
pdnnoob Posted February 17, 2014 Share Posted February 17, 2014 Quote No, Paint.NET is not spyware...but, installing it is an IQ test. ~BoltBait Blend modes are like the filling in your sandwich. It's the filling that can change your experience of the sandwich. ~Ego Eram Reputo Link to comment Share on other sites More sharing options...
heathersharmony Posted February 17, 2014 Share Posted February 17, 2014 techno robbo; I am still having trouble with this. I have done as you instructed and it is duplicating columns also. Can I email you the pdn file so you can see what I am working with? Thanks! Heather Quote Link to comment Share on other sites More sharing options...
heathersharmony Posted February 17, 2014 Share Posted February 17, 2014 pdnoob: the section you have highlighted is an area that I change based on the sheets of pages in the book as well as the height of the book. Say a book is 23.5 cm tall and has 279 sheets the pixel width would be 279 and the pixel height would the 23.5 multiplied by 12. Should I shrink the image to fall under these dimensions? Quote Link to comment Share on other sites More sharing options...
TechnoRobbo Posted February 17, 2014 Share Posted February 17, 2014 (edited) I added 2 pixels to pixel size under the Canvas Size Dialog to add a white border to the image you can send the file to this temporary account: heather@technorobbo.com I'll delete it when I receive the file. Edited February 17, 2014 by TechnoRobbo Quote Go out there and be amazing. Have Fun, TRSome Pretty Pictures Some Cool Plugins Link to comment Share on other sites More sharing options...
pdnnoob Posted February 17, 2014 Share Posted February 17, 2014 Canvas Size DialogMy bad. I took a screenshot of the wrong window. Either way, it's still the "pixels" part of the canvas size dialog that you're supposed to change. Quote No, Paint.NET is not spyware...but, installing it is an IQ test. ~BoltBait Blend modes are like the filling in your sandwich. It's the filling that can change your experience of the sandwich. ~Ego Eram Reputo Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.