Wednesday, 15 April 2015

Resize an image along rows only or columns only in matlab -



Resize an image along rows only or columns only in matlab -

i'm writing function in matlab zoom or shrink image using bicubic interpolation. however, function resizes image along both rows , columns. if want enlarge image along rows only, or along columns only? code far

function pic_new = zoom_image(pic, zoom_value) actualsize = size(pic); newsize = max(floor(zoom_value.*actualsize(1:2)),1); newx = ((1:newsize(2))-0.5)./zoom_value+0.5; %# new image pixel x coordinates newy = ((1:newsize(1))-0.5)./zoom_value+0.5; oldclass = class(pic); %# original image type pic = double(pic); %# convert image double precision interpolation if numel(actualsize) == 2 pic_new = interp2(pic,newx,newy(:),'cubic'); end pic_new = cast(pic_new,oldclass); end

updated: able resize image both along rows , columns. however, doesn't work right

this original image: https://imagizer.imageshack.us/v2/895x383q90/r/903/4jm76i.png

this image after beingness enlarge 2.5 along rows , shrunk 1.3 along columns: https://imagizer.imageshack.us/v2/323x465q90/r/673/ehiaob.png

why there such black box in result image?

updated 2: how did: in command window type

>> img = imread('pic.pgm'); >> newimage = zoom_image(img, 2.5, 1/1.3); >> imshow(newimage)

try editing function have separate zoom rows , columns, la

function pic_new = zoomfunc(pic, zoom_valuex, zoom_valuey) actualsize = size(pic); newsize = max(floor([zoom_valuey zoom_valuex].*actualsize(1:2)),1); newx = ((1:newsize(2))-0.5)./zoom_valuex+0.5; %# new image pixel x coordinates newy = ((1:newsize(1))-0.5)./zoom_valuey+0.5; oldclass = class(pic); %# original image type pic = double(pic); %# convert image double precision interpolation if numel(actualsize) == 2 pic_new = interp2(pic,newx,newy(:),'cubic'); end pic_new = cast(pic_new,oldclass); end

image matlab resize

xaml - Button and .resw idea Windows Phone 8.1 -



xaml - Button and .resw idea Windows Phone 8.1 -

i have button , want content loaded name .resw file. know can alter in page class or in class possible in xaml default option?

my button:

<button content="" horizontalalignment="left" margin="84,480,0,0" verticalalignment="top" width="220" height="42" foreground="#ff0e0e0e"/>

thanks in advance!

you can set x:uid attribute string in resw file.

<button x:uid="sendbutton" />

the key entry in resw file should this:

sendbutton.content

you can add together path resource file in case have multiple files

<button x:uid="/forms/sendbutton"/>

the i18n scheme introduced winrt totally flexible. suggest reading next article more details:

http://msdn.microsoft.com/en-us/library/windows/apps/xaml/hh965323.aspx

xaml windows-phone-8 windows-phone-8.1

c++ - avoiding busy wait with boost::asio poll -



c++ - avoiding busy wait with boost::asio poll -

i'm writing service on linux uses boost::asio::io_service io_service::poll in while loop. busy wait loop, e.g. wastes cpu cycles.

void application::run() { seek { std::cout << "tcpserver starting..\n"; _tcpserver.reset( new tcpserver(_io_service, boost::ref(_spstate)) ); // _io_service.run(); while( ! _spstate->quitsignalled() ) { _io_service.poll(); } std::cerr << "quit signalled, tcpserver stopping.. :/" << std::endl; } catch(std::exception & e) { std::cout << e.what() << "\n"; } }

i utilize poll instead of run check if thread in service has signalled service shutdown.

is there way of achieving without using poll in busy wait loop ?

the service uses async io on single thread, , other threads info processing.

i've added sleep between iterations of loop seems cut down waste of cpu time, hoping there might more efficient way?

void application::run() { using boost::this_thread::sleep_for; static const boost::chrono::milliseconds napmsecs( 50 ); seek { std::cout << "tcpserver starting..\n"; _tcpserver.reset( new tcpserver(_io_service, boost::ref(_spstate)) ); // _io_service.run(); while( ! _spstate->quitsignalled() ) { _io_service.poll(); boost::this_thread::sleep_for( napmsecs ); } std::cerr << "quit signalled, tcpserver stopping.. :/" << std::endl; } catch(std::exception & e) { std::cout << e.what() << "\n"; } }

i'd say, take advantage of fact boost::asio::io_service threadsafe default, , do

iosvc.run();

and signal service shutdown on "another thread in service" would:

iosvc.stop();

remember iosvc.reset() before phone call {run,poll}[_one] again, per documentation.

of course of study can utilize other means signal actual logical workers end, that's independent unrelated boost asio

c++ boost-asio busy-waiting

javascript - Angular app throws error -



javascript - Angular app throws error -

my code this

<div ng-app='myapp' ng-controller="mainctrl"> <div ng-repeat="prdelement in pacakageelement track $index" class="package-grid"> <div style="border: 1px solid; padding-bottom: 10px; padding-top: 10px"> <input placeholder="product code" /> <input placeholder="dimension" /> </div> <table class="hovertable"> <thead> <tr> <th>line #</th> <th>itcls</th> <th>item #</th> <th>line quantity#</th> <th>ship quantity</th> <th>pickquantity</th> <th>quantity in plt</th> <th>allready packed</th> </tr> </thead> <tbody> <tr ng-repeat="data in prdelement.data" ng-init="data.newquantity = data.quantity"> <td>{{data.itemid}}</td> <td>{{data.itcls}}</td> <td>{{data.itemid}}</td> <td>line quantity#</td> <td>ship quantity</td> <td>pickquantity</td> <td> <input type="text" ng-model="data.newquantity" placeholder="quantity" required=required /> </td> <td>allready packed</td> </tr> <tr> <td width="100%" colspan="4"> <button ng-show="prdelement.show" ng-click="newpackageitem( prdelement,$event)">next pallet</button> </td> <td width="100%" colspan="4"> <button ng-show="prdelement.show">remove pallet</button> </td> </tr> </tbody> </table> </div> (function () { angular.module('myapp', []).controller('mainctrl', function ($scope) { var counter = 0; $scope.pacakageelement = [{ name: counter, show: true, data: [{ name: 'item 1', itemid: '284307', itemcode: '', description: 'bicycle parts - frame', quantity: '100', handlingunit: 'ctn', weight: '613.04', class: '', lenght: '102', width: '42', height: '61', flag: 'p' }, { name: 'item 2', itemid: '284308', itemcode: '', description: 'bicycle parts - fork', quantity: '200', handlingunit: 'ctn', weight: '242.99', class: '', lenght: '75', width: '34', height: '18', flag: 'p' }] }]; $scope.newpackageitem = function (packageelement, $event) { var npackageelement = {}; angular.copy(packageelement, npackageelement); counter++; packageelement.show = false; npackageelement.name = counter; angular.foreach(npackageelement.data, function (row) { if (row.quantity != row.newquantity || row.quantity != 0) { row.quantity = row.quantity - row.newquantity; } }); $scope.packageelement.push(npackageelement); }; }); }());

here trying duplicate first dataset , calculations on it. works fine except function newpackageitem. function lone throws error

typeerror: cannot read property 'push' of undefined @ scope.$scope.newpackageitem

fiddle

you misspelled property "packageelement" "pacakageelement". alter instances utilize "packageelement" , should work.

javascript angularjs

Travis sudo is disabled -



Travis sudo is disabled -

i want utilize apt install packages test, however, fails due sudo disabled. found next in test output:

sudo, firefox addon, setuid , setgid have been disabled.

it seems output comes this line in travic-ci, setting paranoid_mode false in .travis.yml not work.

how enable sudo access?

ps: using private repo.

edit: next .travis.yml fail due sudo: must setuid root when running sudo apt-get update -qq

language: python python: - "3.4" before_install: - sudo apt-get update -qq script: - nosetests

setting sudo: true and/or paranoid_mode: false not work.

sudo access turned off on our docker based architecture, used in 2 contexts:

repositories opt in using sudo: true in .travis.yml file (it additionally needs turned on on our side) on our educational programme (see http://education.travis-ci.com)

builds running on our docker based architecture cannot allowed sudo access due security concerns in lxc/docker layer. hope fixed in near future, unfortunately issue out of our own hands.

we working on improving firefox addon, uses sudo itself, shouldn't. we'll post on our blog 1 time has happened.

travis-ci

eclipse - How to always enable command handler in Egit -



eclipse - How to always enable command handler in Egit -

in egit, ..... when right click project, click "show in history", history view shows list of commits, select 1 commit, right click , pop menu shows (checkout, create branch, create tag, .....revision comment). need add together new item in pop menu called "add factory", when click it, go "addtofactoryhandler" implementation.

i want menu item there when right click commit in history view.

class="lang-xml prettyprint-override"><extension point="org.eclipse.ui.menus"> <menucontribution locationuri="popup:org.eclipse.egit.ui.historypagecontributions"> <command defaulthandler="xxxxxxxxxxx.addtofactoryhandler" commandid="xxxxxxxxxx.addtofactory" label="addtofactory" style="push" > </command> </menucontribution> </extension> <extension point="org.eclipse.ui.handlers"> <handler class="xxxxxxxxxxx.addtofactoryhandler" commandid="xxxxxxxxxx.addtofactory"> </handler> </extension>

then in history view, first time select commit, right click , popup menu shows grayed out "add factory". sec time, right click , goes away.

i appreciate help .. thanks!

you need utilize org.eclipse.ui.commands extension point define command id.

also note command in menucontribution not have defaulthandler parameter.

so like:

class="lang-xml prettyprint-override"><extension point="org.eclipse.ui.commands"> <command id="xxxxxxxxxx.addtofactory" defaulthandler="xxxxxxxxxxx.addtofactoryhandler" description="description" name="name"> </command> </extension> <extension point="org.eclipse.ui.menus"> <menucontribution locationuri="popup:org.eclipse.egit.ui.historypagecontributions"> <command commandid="xxxxxxxxxx.addtofactory" label="addtofactory" style="push" > </command> </menucontribution> </extension> <extension point="org.eclipse.ui.handlers"> <handler class="xxxxxxxxxxx.addtofactoryhandler" commandid="xxxxxxxxxx.addtofactory"> </handler> </extension>

eclipse git plugins

scala - Why TypeTag doesnt have method runtimeClass but Manifest and ClassTag do -



scala - Why TypeTag doesnt have method runtimeClass but Manifest and ClassTag do -

i have code generically transform string dto, if using manifest , classtag, both of can utilize method runtimeclass runtime class, typetag doesnt have method

class objectmapper[t] { def readvalue(x: string, t: class[t]): t = ??? } class reader { def read[w: manifest](x: string): w = { val mapper = new objectmapper[w] mapper.readvalue(x, implicitly[manifest[w]].runtimeclass.asinstanceof[class[w]]) } }

may know why typetag doesnt have method runtimeclass

many in advance

assuming typetag comes scala.reflect.runtime.universe, can class this:

def runtimeclass(tag: typetag) = tag.mirror.runtimeclass(tag.tpe)

it doesn't have method because not typetags runtime universe.

scala